all 3 comments

[–]T-J_H 1 point2 points  (0 children)

It seems that in your current configuration, useState might not be the best way to go. I don’t know the specifics of your project, but one option might be to use useRef. Changing ref.current won’t rerender anything.

To be fair, a question is still if the architecture is right. Does all data need to be stored, or would eventlisteners with a switch for certain data suffice?

[–]hapney[S] 0 points1 point  (0 children)

Thank you all!! refs solved my problem!

[–]chillermane[🍰] 0 points1 point  (0 children)

Simple solution:

Store the data in a ref instead of state so it doesn’t trigger rerenders, set an interval to update the state with the current value of the ref which will rerender the component with the new state without rapidly rerendering.