Reputation: 781
As per title, my React child component does not re-render when a prop changes value. I have created an example here:
https://codesandbox.io/s/x9mzwnj04p
I tried using ComponentWillReceiveProps but it does not get called.
Upvotes: 1
Views: 86
Reputation: 9063
You've got the variable name wrong. The prop name you pass down to the child component is called someValues
:
<ChildComponent handleClick={(e) => this.handleClick(e)} someValues={someValue} />
But when assigning it in the child you type someValue
, which is missing the 's':
const { handleClick, someValue } = this.props
You need to fix the name and add the 's':
const { handleClick, someValues } = this.props
And then change it in the returned JSX:
<span>{someValues ? 'true' : ' false'}</span><br /><br />
Upvotes: 1