Why are React props immutable?

A component should manage its own state, but it should not manage its own props. props is essentially “state that is managed by the component owner.” That’s why props are immutable.

React docs also recommends to treat state as if it’s immutable.
That is because by manipulating this.state directly you are circumventing React’s state management, which can be potentially dangerous as calling setState() afterwards may replace the mutation you made.

Leave a Comment