kratos-selfservice-ui-react-nextjs icon indicating copy to clipboard operation
kratos-selfservice-ui-react-nextjs copied to clipboard

Should the session be fetched on each rerender on index page?

Open spietras opened this issue 2 years ago • 1 comments

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?

spietras avatar Mar 11 '22 12:03 spietras

Yes, that makes sense to me!

aeneasr avatar Mar 18 '22 10:03 aeneasr