How to force a component to re-render?

is there a way to force a component to rerender or otherwise force a useState to take effect immediately?

I think you should take a look at useEffect in react (here’s a tutorial). If I understand what you’re asking, this should do what you want.

disclaimer: I’m still learning this stuff myself, so there might be a better way.

useState is for values that should cause a rerender

useEffect is for additional logic that gets triggered when values in it’s dependency array have changed. (during the previous rendering cycle)

and yes there are some sneaky (arguably dirty) techniques to force rerenders: