Does anyone know why `const {userId} = useSessionC...
# support-questions
a
Does anyone know why
const {userId} = useSessionContext();
would return
DEFAULT_USER_ID
?
r
Yes. You need to wrap the component with the auth wrapper that we have.
a
Could you point me to that part of the docs please? Thanks
a
Thanks mate much appreciated
r
thats for thirdpartyemailpassword recipe. If you are using another recipe, please navigate to that recipe's docs instead
there should be a similar section in the other recipe docs
a
Ah so that is in place
It was working as I said, itโ€™s in my app tsx along with my routing set up. Will double check later today though
r
sounds good!
a
so this is how i have it set up:
Copy code
html
 <Route path="/" element={
   <ThirdPartyEmailPasswordAuth>
     <Context.Provider value={{
         todos: todos ?? []
      }}>
        <Header />
        <TodoList />
      </Context.Provider>
    </ThirdPartyEmailPasswordAuth>
 } />
oh dear, that indentation came out wonky
r
That should work.
If you are using
ThirdPartyEmailPassword
recipe.
a
yeah it's weird, it was, then all of a sudden wasn't
r
is it still not working?
a
obviously something changed but I can't work out what it is
nah, still not working
r
In which component are you using
useSessionContext
?
In the
TodoList
?
a
wait
thank you!
I reworked the app to use context rather than props and that meant moving my authenticated api calls upwards
so at the moment the component where I make api calls isn't wrapped
that must be it?
r
You can wrap your whole app with:
Copy code
import {SessionAuth} from "supertokens-auth-react/recipe/session"

<SessionAuth requireAuth={false}>
  <App />
</SessionAuth>
And this way, the
useSessionContext
can be used anywhere in your app
a
Sweet, I'll do that. Thank you very much for your time
r
(As long as the app is client side rendered)
a
it is ๐Ÿ˜„
3 Views