0

Basically, i want to find difference in between nextprops and nextState. both are contains an array with the objects. if any different between props then i will add that particular props to the state.

componentWillReceiveProps(nextProps, nextState) {

}

i was able to find npm package call react-addons-shallow-compare but it doesn't work for me. please find the code below.

componentDidUpdate(prevProps, prevState) {
    console.log("nextProps.workers && this.state.fetchAction ",prevProps," && ",prevState);
    let status = shallowCompare(this, prevProps, prevState);
    console.log("status ",status);

}

Every time it return true. even if props are two different. please help me the figure this out.

1 Answers1

0

If you're using underscore, you could just do

_.isEqual(this.props, nextProps);
Borjante
  • 9,767
  • 6
  • 35
  • 61