Skip to content Skip to sidebar Skip to footer

Setting State From Render Const

I would like to setState, in my case, feedbackLogId, which is required to called a function that will GET the details of feedback according to the feedbackLogId. The const, however

Solution 1:

Try to use getDerivedStateFromProps

static getDerivedStateFromProps = (props, state) => { 
    console.log('props',props.navigation)
    const feedbackLogId = props.navigation.getParam('value', 'nothing');
    if(feedbackLogId){
    this.getPendingDetails(feedbackLogId);
    }
  }  

In your constructor

this.getPendingDetails = getPendingDetails.bind(this) 

to

this.getPendingDetails = this.getPendingDetails.bind(this)

Post a Comment for "Setting State From Render Const"