You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
setState callback is not executed when working with subscriptions on behaviorsubjects/observables
To Reproduce
componentDidMount() {
// this logs 'test 1: true' to the console
this.setState({ test: true }, () => { console.log('test 1 : ', this.state.test)})
this.dataService.configuration$.subscribe(data => {
// this correctly logs the data received from the subscription
console.log('test 2 : ', this.data)
this.setState({
data: data,
}, () => {
// this is never logged
console.log('test 3 : ', this.state.data)
});
});
// this is also never logged
this.setState({ test: true }, () => { console.log('test 4 : ', this.state.test)})
// this correctly logs the data from the state
// proving that the state is set correctly but the callback is never executed
window.setTimeout(() => { console.log('test 5: ', this.state.data)}, 1000)
}
The setstate callback is never executed when called from within a subscription or after a subscription.
It works fine before the subscription, and the state is always set correctly.
When using v 10.5.14 this works fine.
Expected behavior
I would expect the setstate callback to run within or after subscriptions.
The text was updated successfully, but these errors were encountered:
Describe the bug
setState callback is not executed when working with subscriptions on behaviorsubjects/observables
To Reproduce
The setstate callback is never executed when called from within a subscription or after a subscription.
It works fine before the subscription, and the state is always set correctly.
When using v 10.5.14 this works fine.
Expected behavior
I would expect the setstate callback to run within or after subscriptions.
The text was updated successfully, but these errors were encountered: