Question
What does it mean that props “can only be changed by a different component?”
Answer
Once a component receives props, those props cannot be changed by it. Only the parent component which sent the props, or some component that is an ancestor of the child component receiving the props, is able to change the value to something else.
The parent component may change its state at times, and this can trigger a re-render of the child component receiving the props, with new values.
1 Like
From the lesson: “Don’t Update props”
A React component should use props
to store information that can be changed, but can only be changed by a different component.
The above message sounds not correct, since a Child component cannot change the props
of its Parent!!!
A React component should use state
to store information that the component itself can change.
Shouldn’t they be? …
A React component should use state
to store information that can be changed, but can only be changed by a different component.
A React component should use props
to store information that the component itself can change.