setState
callback does not behave as expected, setState
provide a callback to be called after the state changes,
and the callback is an action of redux:
addressInput = e => {
this.setState({
address: e.target.value
},
this.props.filterSearch(this.state.address));
}
I get this error
Warning: setState(...): Expected the last optional
callback
argument to be a function. Instead received: [object Promise].
It expect a "last optional callback argument to be a function".
Write it like this:
addressInput = e => {
this.setState({
address: e.target.value
},
() => this.props.filterSearch(this.state.address))
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With