3 ms·
That's a misuse of useEffect. it's much simpler to wrap the set function and just call your other function afterward like this: ``` const handleChange = (valu
by schwartzworld 7y ago
That's a misuse of useEffect.
it's much simpler to wrap the set function and just call your other function afterward like this:
```
const handleChange = (value) => {
setMyState(value);
doSomething();
}
```
- mstudio 7y agoThis does not work. setMyState() is asynchronous. doSomething() would run, but not necessarily with the updated value of the state.
- schwartzworld 7y agoThen make the wrapper function async and await setMyState?