score:1

Accepted answer

you need to use the componentwillreceiveprops lifecycle method it will get called whenever any change happens to props values so at that time you need to update the state value.

use this:

componentwillreceiveprops(newprops){
    this.setstate(newprops.contactinfo);
}

componentwillreceiveprops:

componentwillreceiveprops() is invoked before a mounted component receives new props. if you need to update the state in response to prop changes (for example, to reset it), you may compare this.props and nextprops and perform state transitions using this.setstate() in this method.


Related Query

More Query from same tag