I am new to react. This is a generated code block in my project by create-react-app
const container = document.getElementById("root");
const root = createRoot(container);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
Now I am using gsap to render anime. There is a disgusting blank block at the top of the page. Finally I found out the reason is these code, I also find out the solutions, but I do not know why.
1. ReactDOM.render
with <React.StrictMode>
success.
2. createRoot.render(<App />)
success.
3. createRoot.render()
with <React.StrictMode>
FAILED.
Here is the project
Can anyone explain these differences?
———Edit———–
context is a solution, but it’s broken again after add another <div id='img2'>
for animation
2
Answers
Should use ScrollTrigger in this way
From the
gsap.context()
documentation:codesandbox