react-typical icon indicating copy to clipboard operation
react-typical copied to clipboard

Every rerender causes a new instance to be attached

Open austincondiff opened this issue 3 years ago • 2 comments

I am using react-scroll-parallax and I am seeing an issue where if it rerenders on scroll in my case, a new instance of typical is attached to the element resulting in very janky visuals.

https://user-images.githubusercontent.com/806104/171450237-d8f226c7-498f-4b8a-a311-19f6b90b770c.mp4

Edit: Wrapping it in a PureComponent fixes the issue, but I feel like I shouldn't need to do this.

austincondiff avatar Jun 01 '22 16:06 austincondiff

I am using react-scroll-parallax and I am seeing an issue where if it rerenders on scroll in my case, a new instance of typical is attached to the element resulting in very janky visuals.

Screen.Recording.2022-06-01.at.11.00.19.AM.mp4 Edit: Wrapping it in a PureComponent fixes the issue, but I feel like I shouldn't need to do this.

Have you solved this? I could not figure it out. Do you have any alternate solutions?

prashant54singh avatar Sep 02 '22 07:09 prashant54singh

Yeah, use a PureComponent. The problem was that it rerendered every scroll event and each time it did, a new animation was applied to the text on top of the existing animation. Putting it in a PureComponent tells React not to rerender it after it first mounts. If there is a better way to do this, I'd love to hear but this was the best I could do to fix it.

austincondiff avatar Sep 02 '22 08:09 austincondiff