kratos-selfservice-ui-react-nextjs
kratos-selfservice-ui-react-nextjs copied to clipboard
Should the session be fetched on each rerender on index page?
If I understand correctly, useEffect
without any dependencies will be fired on each rerender. If that's the case then we would do unnecessary calls to Kratos, because useEffect
will be fired again after we call setSession
the first time.
https://github.com/ory/kratos-selfservice-ui-react-nextjs/blob/b3d26868f8eea281480b1ec5053ecab658ca5c19/pages/index.tsx#L19-L44
Should we add an empty array []
as useEffect
dependency so it fires only once? Or maybe there is some different reasoning as to why there are no dependencies in this useEffect
?
Yes, that makes sense to me!