preact: While testing shouldComponentUpdate it seems that the this.props.children never equals nextProps.children

I 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

render red

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

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 24 (17 by maintainers)

Most upvoted 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!

@Download 7.2 was only released under the beta dist-tag. When you do npm i preact you are only ever going to get latest dist-tag releases. I just rolled 7.2 over to latest though, so npm i preact should now give you 7.2 😃