more of a design question, but is there some stand...
# support-questions-legacy
o
more of a design question, but is there some standard way of making supertokens-react work with something like react-query? react-query provides a useQuery hook which fetches data from the backend on first render. however, if the session is still loading, this will fail, but returning null if the session is loading is not an option either, since react does not allow conditional hooks (returning before useQuery is not allowed).
r
hey
@porcellus can help with this
p
hi
I'll check in a sec.
at first glance I see 2 options. As a generic solution, if you wrap your component in
SessionAuth
with
requireAuth=true
then the component will only render after the session has been loaded (and exists). You could use your own wrappers around the component too if you have more complex requirements. Specific to react-query, I think it takes an
enabled
option you can set to false while the session is loading.
o
awesome! for the second option, does supertokens cause a rerender when the session is loaded?
p
yep
o
neat, thanks!
p
happy to help 🙂
r
Thanks @porcellus