set state for two components in a funtion react code example
Example 1: this setstate previous state react
state = {count: 0}
increment = () => {
this.setState(previousState => ({
count: previousState.count + 1
}))
}
Example 2: set state
setState({ searchTerm: event.target.value })