reactjsreact-class-based-component

Is `this.props` possible to be changed in the component itself?


As the title says, is this.props possible to be changed in the component itself whether manually or automatically

manual change example

this.props.someData = 'some value'

I don't know how to change this.props automatically, so I can't write example of automatical change.


Solution

  • Like @mousetail suggested, it's best practise to add an updater callback to the props:

    this.props.updateData(value);