I have two components. Child component will open in modal box. Modal box component will contain add and edit the user. I have passed some values for modal box input and getting that value in getDerivedStateFormProps life cycle hook. Initially it's populating the value to input value. But after that if type anything in the text box state is not updated. Please see the details below
static getDerivedStateFromProps(props, state) {
state.show = props.show;
state.company = props.company;
return state;
}
onChange = async(e) => {
this.setState({company: {...this.state.company, [e.target.name]: e.target.value}});
}
But the state is not updating. Could anyone please provide help to resolve the issue. Thanks in advance.