I usually update state in react to toggle a icon display in react:
  toggle = () => {
    this.setState({
       open: !this.state.open
    })  // setState
  } // toggle callback
Now I saw a new way of doing it, which is recommended over the above way:
  toggle = () => {
    this.setState((prevState, props) => {
      return {
        open: !prevState.open
      } // return
    })  // setState
  } // toggle callback
In this case, the setState function consumes a updater(which in this case is a callback function), which worked. how does the setState function consumes the updater? The second parameter in updater props was not even used, what is the use of it?
 
     
     
    