Reputation: 1593
I have a functional component that is being rerenderd, and because it has a css animation in it, the animation starts from the beginning causing weird visual issues.
Any ideas how to fix this?
Upvotes: 0
Views: 81
Reputation: 1593
I exported the scrollaction wrapped with memo and that worked for me :)
export default memo(ScrollAction);
Upvotes: 0
Reputation: 3860
You can wrap it in React.memo() wrapper. As long as it does not receive new props during a re-render, it's not going to re-render.
// You use the wrapper like this:
const ScrollAction = React.memo((props) => {
// Your ScrollAction Component
})
Upvotes: 2