setState Doesn't Update the State Immediately in functional component code example
Example 1: setstate not updating state immediately
myFunction = () => {
this.props.updateItem(this.state)
}
Example 2: setstate not updating state immediately
this.setState({pencil:!this.state.pencil}, myFunction)