question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:24 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
developitcommented, Feb 7, 2017

Ack! I messed up and the dist-tag change hadn’t gone through. It’s there now and I updated the releases page.

1reaction
Downloadcommented, Feb 6, 2017

Ha that explains it! Thanks Jason!

Read more comments on GitHub >

github_iconTop Results From Across the Web

While testing shouldComponentUpdate it seems ...
While testing shouldComponentUpdate it seems that the this.props.children never equals nextProps.children #374.
Read more >
How can I compare this.props.children with nextprops. ...
In componentWillReceiveProps I need to compare this.props.children with the children in nextprops. I can iterate over either structure with React.Children.
Read more >
React.Component
This page contains a detailed API reference for the React component class definition. It assumes you're familiar with fundamental React concepts, ...
Read more >
Pass Multiple Children to a React Component with Slots
This component needs to be able to accept multiple children and place them in the layout as it sees fit – not right...
Read more >
Using componentDidUpdate in React
In this article we will see how to use the componentDidUpdate function ... in its state and pass this value to the child...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found