navigate - Wait for navigation to finish
Hello, I'm reevaluating SolidJS and somehow it started really click in my head. There's one thing that I'm trying to do right now, basically I'm wrapping my whole app with UserProvider and and to expose two 'hooks'
useUser
and useMaybeUser
with the only difference between them being that useUser
would enforce that user is present or navigate you to login page.
Here's what I came up with for now.
This code seems to be triggering 'unreachable' error. I'm wondering what would be the best way to wait for navigation to finish so 'unreachable' error is actually never reached?1 Reply
Hmm, I think that it might not be such a good idea to do this after all. It seems like Context is resetting on every edit (HMR?) and
useUser
redirects me to login even if I was alreayd logged in.
Oh, I think if I move context to another file it will be fine 😆
Okay, I think I've found solution. useNavigate
navigates within SolidJS app so I use window.location.replace
now which seems to do the trick.