React · Junior · Question 8 of 75
Can you modify props inside a child component?
- 1Yes: React notices the change and re-renders the parent component
- ✓Correct answer: No: props are read-only; the data's owner should change it
- 3Yes, if the prop is an object or array rather than a primitive
Explanation
Props are the component's inputs, and it must not mutate them. For a child to change data, the parent passes it a callback (onChange) and keeps the state itself. Mutating an object from props won't trigger a re-render and creates hard-to-find bugs.