When calling setState after awaiting for another function and logging the state to the console - the value is immediately available.
I know that setState is asynchronous and in all other cases, it wouldn't be available immediately after calling it (but would be available in the setState callback)
When used without await (expected)
// inital value state is 0
const response = fetchSomething()
this.setState({
value: 5
})
console.log(this.state.value) // prints 0
Used with await
// inital value state is 0
const response = await fetchSomething()
this.setState({
value: 5
})
console.log(this.state.value) // prints 5
What am I missing here?