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

Fix broken SSR on master #310

Merged
merged 7 commits into from
Jun 18, 2019
Merged

Fix broken SSR on master #310

merged 7 commits into from
Jun 18, 2019

Conversation

andyrichardson
Copy link
Contributor

@andyrichardson andyrichardson commented Jun 18, 2019

It looks like the SSR reproduction on the current master is broken (looks to be related to #296).

UnhandledPromiseRejectionWarning: Error: [react-ssr-prepass] Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)

To get around the late call of useEffect (causing problems in both SSR and browser environments) we now use useLayoutEffect.

This also addresses the issue I've been seeing locally where super fast network responses cause the state not to be updated.

@JoviDeCroock
Copy link
Collaborator

If you want I can test it against the reproduction case provided in: https://codesandbox.io/s/nostalgic-sound-psbzf?fontsize=14

@andyrichardson
Copy link
Contributor Author

@JoviDeCroock that's awesome! I'll give it a shot

Copy link
Member

@kitten kitten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome investigative work here 🚀 lets ship it!

@andyrichardson andyrichardson merged commit 40e371b into master Jun 18, 2019
@andyrichardson andyrichardson deleted the fix-ssr branch June 18, 2019 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants