-
I am using Next and have a statically generated page that checks if the current user is logged in after it loads. I would like to use useSWR to fetch updated data on this page only if the current user is logged in. The check to determine whether they are logged in takes about a half second. Once the state is updated with the logged in status, is it supported to change the conditional in useSWR? Something like this? const [session, loading] = useSession();
const { data } = useSWR(!loading && session ? '/api/data' : null, fetcher) |
Beta Was this translation helpful? Give feedback.
Answered by
sergiodxa
Oct 10, 2020
Replies: 1 comment
-
Yes, that should work without issues |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
bscaspar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, that should work without issues