Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isLoading should default to true even when doing SSR #193

Merged
merged 2 commits into from
Feb 5, 2021

Conversation

adamjmcgrath
Copy link
Contributor

@adamjmcgrath adamjmcgrath commented Feb 4, 2021

Description

I originally thought isLoading should initialize as false when doing SSR, the logic being that the SDK will never start loading during SSR so isLoading didn't make sense to be true

However, the output of SSR rendering is rendered on the client, to be hydrated, so a client will expect it to be initialised as true. If it's false, then immediately hydrated as true you get Warning: Expected server HTML to contain a matching <div> in <div>. because it's been rendered in a different state that the ReactDom.hydrate is expecting.

Whilst this will change initial rendering behaviour, it shouldn't break anyone - just remove the warning.

References

fixes #182

Testing

I've changed the SSR tests to use ReactDOMServer.renderToString rather than renderHook because renderHook still expects to be called in a jsdom environment.

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

@adamjmcgrath adamjmcgrath added the review:small Small review label Feb 4, 2021
@adamjmcgrath adamjmcgrath requested a review from a team as a code owner February 4, 2021 16:33
@adamjmcgrath adamjmcgrath merged commit 2ca701e into master Feb 5, 2021
@adamjmcgrath adamjmcgrath deleted the ssr-is-loading branch February 5, 2021 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review:small Small review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting isLoading to false in SSR mode causes server/client state mismatch
2 participants