Email or username:

Password:

Forgot your password?
Top-level
Josh Lee

@darius would be very curious to hear what the attempt was

2 comments
Darius Kazemi

@jleedev basically I gave components

A
B C
D

C needs to change how it behaves on click based on state of D. Raising state to A and passing down causes a rerender of the whole tree on state change, which I can't have. I tried 6 or so tricks including refs, usecallback, context, reducer & dispatch instead of state, etc. Nothing worked to prevent the rerender so now C just queries the DOM to see if D has a certain class.

Max

@darius

Idiomatic React would suggest if you are worried rerender times in the tree you may have something else possibly unrelated wrong (calls to a Class.render or functionComponent are expected to be fast because they may be called often in the virtual DOM approach). React generally airs on the side of caution that shared state is a full rerender: if the state change in A then yeah everything under A generally rerenders.

@jleedev

Go Up