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

feat: add test to reproduce #605 #1

Merged

Conversation

jonaskinnvall
Copy link
Owner

@jonaskinnvall jonaskinnvall commented Oct 31, 2022

What:

This fixes a bug that assumes that tests don't run in SSR environments.

Why:

With frameworks like Next.js and Remix rendering components on the server, it's important that this library can mimic SSR environments as closely as possible.

How:

First by adding a test that reproduces the issue and then by moving this logic "into the hydrate function, so we reference document when they want it to render for real." (suggested by mpeyper).

Checklist:

  • Documentation updated
  • Tests
  • Ready to be merged
  • Added myself to contributors table

@jonaskinnvall
Copy link
Owner Author

L37, “✍🏼 If container is undefined, then we pass null to hydrate since undefined is not a valid container, but null is.”

@jonaskinnvall
Copy link
Owner Author

L52-54, “✍🏼 Since act returns a function, it introduces a new scope which means we need to check again that container is not undefined before using it. This means we could remove the outer if (container) { check if we're okay that unmount always returns act”.

@jonaskinnvall jonaskinnvall marked this pull request as ready for review November 6, 2022 09:59
@jonaskinnvall jonaskinnvall merged commit 165b51a into jonaskinnvall-fix-ssr-before Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant