While testing shouldComponentUpdate it seems that the this.props.children never equals nextProps.children
See original GitHub issueI was doing some testing on https://github.com/tkh44/shallow-compare and it seems that shouldComponentUpdate will always fail based on props being different. The property children
is always different.
I may be missing something or doing something wrong in my tests, but I felt like I should ask about it.
I created a branch with a logging so the issue could be seen here: https://github.com/tkh44/shallow-compare/tree/testing-preact-children. It is set up just like most of preact’s family of repos so just npm install
and npm t
.
Here is what i’m getting in the logs
prevProps {“color”:“red”,“children”:[“test”]} nextProps {“color”:“blue”,“children”:[“test”]} color is not equal value a: red value b: blue propsDiffers true stateDiffers false shouldComponentUpdate true color is not equal value a: red value b: blue propsDiffers true stateDiffers false render blue
prevProps {“color”:“blue”,“children”:[“test”]} nextProps {“color”:“blue”,“children”:[“test”]} children is not equal value a: [ ‘test’ ] value b: [ ‘test’ ] propsDiffers true stateDiffers false shouldComponentUpdate true children is not equal value a: [ ‘test’ ] value b: [ ‘test’ ] propsDiffers true stateDiffers false render blue
Issue Analytics
- State:
- Created 7 years ago
- Comments:24 (17 by maintainers)
Top GitHub Comments
Ack! I messed up and the dist-tag change hadn’t gone through. It’s there now and I updated the releases page.
Ha that explains it! Thanks Jason!