JavaScript componentWillReceiveProps is getting previous props - Reactjs [duplicate]

This question already has an answer here:
Answer:1

The new props will be in variable newProps. So you have to use newProps.tab to get the incoming prop.

componentWillReceiveProps(newProps) {
  const currentTab = newProps.tab;
  console.log("CURRENT TAB IN WILL PROPS:"+currentTab);
  this.setState({
    currentTab: currentTab
  })
}

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.

https://reactjs.org/docs/react-component.html#componentwillreceiveprops

Answer:2

I have the below line of java script, which aims to split a string and replace the value at the splitted section with the new value. I appreciate this could be done with a 2-dimensional array, but I ...

I have the below line of java script, which aims to split a string and replace the value at the splitted section with the new value. I appreciate this could be done with a 2-dimensional array, but I ...

var people = [ ["nan", "30", "female", ["4545345454", "4324324324"]], ["ban", "35", "male", ["4324234234", "7576343243"]], ["san", "38", "male", ["3242342343", "3423423434"]] ]; //var k=0; ...

var people = [ ["nan", "30", "female", ["4545345454", "4324324324"]], ["ban", "35", "male", ["4324234234", "7576343243"]], ["san", "38", "male", ["3242342343", "3423423434"]] ]; //var k=0; ...

I am writing a chrome extension that modifies elements properties as a page is loaded or changes. I do this using a Mutation Observer. However the observer's handler is not called when shadow-dom (ie,...

I am writing a chrome extension that modifies elements properties as a page is loaded or changes. I do this using a Mutation Observer. However the observer's handler is not called when shadow-dom (ie,...

I've been struggling with this problem for a while now, and it seems like google has made a lot of minor changes to the Google Charts API over the years, which has been making it even harder to find ...

I've been struggling with this problem for a while now, and it seems like google has made a lot of minor changes to the Google Charts API over the years, which has been making it even harder to find ...

  1. more than google
  2. more than one google voice number
  3. more than one google account
  4. more than one google home
  5. more than one google drive account on computer
  6. more than one google home mini
  7. more than one google calendar
  8. more than 1 google voice number
  9. more than one google drive on computer
  10. more accurate than google translate
  11. more than blue google drive
  12. more than one google chrome in task manager
  13. more than one google home in house
  14. more accurate than google maps
  15. more than one google account on android
  16. more updated than google earth
  17. more than 10 google maps
  18. more than one google drive
  19. more than 3 google wifi points
  20. more than one google mini