setState() does not always immediately update the component. It may batch or defer the update until later. This makes reading this.state right after calling setState() a potential pitfall. 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)