Race condition with beforeLoad and routerContext
I have a function that does the following in a mutation:
If I remove the
setTimeout
, I get a null value for token
in my beforeLoad
of /user
.
How can I avoid this race condition?3 Replies
correct-apricotOP•14mo ago
Think this may be answered in the
Routing with async data
post below, will give the useEffect trick a shot
yea thats a bit different, the login
function on mine should be synchronous and thus finish + update context before calling navigate
but navigate
fires before the context resets
this is probably some basic React problem 🤔
yep, simple react problem with context and state.
onSettled
also works here in the mutationfascinating-indigo•14mo ago
I had the same issue maybe I would try a useEffect
jolly-crimson•14mo ago
i throw a promise, and wrap my applicaiton in suspense, until authentication has been loaded :))