Another way to solve this is to use `useEffect`. You need to treat useState as you would handle events. The value is available "at some point" and useEffect, with its dependencies set to that state value, trigger when the value changes. Then you can do your magic.