I want to execute a function in Child Component after props gets changed in the Parent Component without having to manage an extra state in Child/Parent.
<ParentCompoenent
myCallback={() => {}}
myList={['a','b','c']}
/>
ChildComponent.js
componentWillReceiveProps(nextProps) {
console.log(this.props.myList, '==', nextProps.myList); // Outputs ['a','b','c'] == ['a','b','c']
}
When I'm trying to console the nextProps in componentWillReceiveProps its giving the same result every time even after the props have been changed.
Not sure what your question has to do with react redux but here is your code not showing the behavior you describe (there is nothing wrong with the code you posted in your question). Please provide a minimum reproducible example of your problem.
You should avoid using componentWillReceiveProps and maybe make the component a functional component and use the useEffect hook or use did mount, did update and possibly will unmount for class components.