After an API call setState is not being triggered. The first console.log statement works as expected and displays all the empty objects from my constructor function, but the callback to setState is never triggered and state is not updated. I've let it sit like this for over 10min.
I have no console errors.
The strange part is that when I am working in another part of the app it magically begins working again and I have no idea why. Am I missing something obvious?
componentDidMount() {
this.init()
}
init() {
getDashboard()
.then(function(data) {
console.log(this.state)
this.setState({
dashboard: data.dashboard,
learning: data.learning,
items: data.items
}, () => {console.log(this.state)})
}.bind(this))
}
I get the same result when I remove the second console.log() from the setState callback and simply place it directly after it.
console.log(this.state)
this.setState({
dashboard: data.dashboard,
learning: data.learning,
items: data.items
})
console.log(this.state)
After an API call setState is not being triggered. The first console.log statement works as expected and displays all the empty objects from my constructor function, but the callback to setState is never triggered and state is not updated. I've let it sit like this for over 10min.
I have no console errors.
The strange part is that when I am working in another part of the app it magically begins working again and I have no idea why. Am I missing something obvious?
I get the same result when I remove the second
console.log()from thesetStatecallback and simply place it directly after it.