I'm basically new to this react hook things, and I'm quite a bit confused. I know that react don't immediately update the state every time setState is called, but the setState method on the class-based component has a callback, which will be called after the state updated. I'm looking for a similar thing on Hook but found nothing yet.
You can use useEffect hook to call a function whenever a value is updated
const [value, setValue] = useState(initialValue);
useEffect(() => {
console.log('Print updated value and do some processing here', value);
}, [value]);
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