as far as i understand, the "children" prop is always re-created and receives a new reference.
using the "pure" hoc on components with children is almost like writing shallowEqual(...) || true meaning we pay the price of shallowEqual but still always re-render.
so i suggest doing one of the two:
pureWithChildren function that works like useShallowEqual from the following repository (that by the way explains the problem i raised in detail:may you just try before writing ;-) It is a good exercise why it works as expected. Ill close this as you are not right
btw seems I got you, what if children passed from the top component, component must be rerendered its expected behaviour
If you need behaviour from that lib please use that lib
was a little lazy to do it but here is a sandbox.
don't you think in this case the component should not re-render?
https://codesandbox.io/s/w2k4vlp1j5
i think people who make their components "pure" should at least be warned in the readme about this behaviour
The behavior of pure is same as React.PureComponent, so I think there is no need to add a warning. By the way, you might want to have a look at this babel plugin.
Most helpful comment
was a little lazy to do it but here is a sandbox.
don't you think in this case the component should not re-render?
https://codesandbox.io/s/w2k4vlp1j5
i think people who make their components "pure" should at least be warned in the readme about this behaviour