You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Correct me if Im misunderstanding something but this plugin shouldn't be worried about shouldComponentUpdate() returning false in line 37 of the component for it's children. This just prevents it's child nodes line 15 of the component from rerender and has no bearing on the Parent <Target> node itself right?
When a component updates, the instance stays the same, so that state is maintained across renders. React updates the props of the underlying component instance to match the new element
Any components below the root will also get unmounted and have their state destroyed.
So if the component is maintained across renders is there anything i'm missing as to why you're setting shouldComponentUpdate() like that?
(I also made this example pen to illustrate what shouldComponentUpdate() is doing if it helps)
The text was updated successfully, but these errors were encountered:
@garrettmac Right, the things that you mention above stand true for cases when a child component manages its state internally via setState() calls. However, another use case is when a child update is triggered by a parent passing new props to it (such as in Flux/Redux flows), and in this case, making shouldComponentUpdate() return false stops the propagation of props from parents to children, and thus the child components are never re-rendered.
We need to do this, because once at.js makes some modifications to the React-generated DOM we need these changes to be persisted (and not overwritten by a subsequent re-render when some child component updates), and the most straightforward way to do it is by disabling re-rendering of the children that the Target component wraps..
Correct me if Im misunderstanding something but this plugin shouldn't be worried about
shouldComponentUpdate()
returningfalse
in line 37 of the component for it's children. This just prevents it's child nodes line 15 of the component from rerender and has no bearing on the Parent<Target>
node itself right?Take the following:
According to the react docs React will replace the first node that it detects change.
Further:
So if the component is maintained across renders is there anything i'm missing as to why you're setting
shouldComponentUpdate()
like that?(I also made this example pen to illustrate what
shouldComponentUpdate()
is doing if it helps)The text was updated successfully, but these errors were encountered: