context provider's values are not being updating after useContext gets user session info.
I am trying to use a context provider to be able to easily call my users data from any of the pages/routes. Originally, when I would try to read the data from my useAuth.user it would return "undefined" which lead me to adding a default value in AuthContextData. Now it inly shows the default data and it does not update the user or isLoading. I do not know what I am doing wrong,
testing in the login page
Routes:
2 Replies
Looks very βReact-likeβ π
Have a look at createResource.
This will remove 90% of your code as it automatically gives you the fetching state:
https://docs.solidjs.com/reference/basic-reactivity/create-resource
Or have a look at the with-auth example of solid-start. You do not need a Context but can use createAsync with cache, have an encrypted, httponly cookie etc.
https://github.com/solidjs/solid-start/tree/main/examples/with-auth/src
GitHub
solid-start/examples/with-auth/src at main Β· solidjs/solid-start
SolidStart, the Solid app framework. Contribute to solidjs/solid-start development by creating an account on GitHub.
Using createResource fixed my problems. Thank you! For anyone's future reference, I removing <AuthProvider> and basiclly all the code I had in my context file. The only code I need