Getderived do Estado alternativo

class PartiallyControlledInput extends React.Component {
  state = {
    value: this.props.value,
  };  componentWillReceiveProps(nextProps) {
    if (nextProps.value !== this.props.value) {
      this.setState({ value: nextProps.value });
    }
  }  render() {
    return (
      <input
        onChange={(e) => this.setState({ value: e.target.value })}
        value={this.state.value}
      />
    );
  }
}
Alexander Mbelle