NoamELB/shouldComponentUpdate-Children

Child that receives new props wont update if father wont update

Closed this issue · 1 comments

hey!
do you still maintain the library?

please look at this sandbox:
https://codesandbox.io/s/43lzn1nr5x

looks like updating children without updating their father doesn't work.

Hi @vzaidman, this is how React (and this library) works.
see: https://github.com/NoamELB/shouldComponentUpdate-Children#our-solution (the bold parts)
AButton won't render, because you implemented the shouldComponentUpdate in it and only 'children' prop is changing. This means that ChildComponent won't render, as it only rendered inside AButton (line 24 in your sandbox example).

If you want AButton to be rendered when 'counter' prop is changing, you should explicitly do so: https://codesandbox.io/s/qln4rk5nnw (see line 61 for my addition).

ChildComponent has no shouldComponentUpdate implementation, therefore it will render every time AButton is rendered.