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(SSR): add support for initial SSR render #322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tujoworker
Copy link

@tujoworker tujoworker commented May 25, 2022

Fixes #321 (more details in this issue)

This PR adds support for in "initial sync render". With that, we do support SSR again.

  • A new property to skip that behavior was added: skipInitialRender.
  • For performance reasons we run the initial render once and omit the second from inside useEffect – else the code render would have to render twice.

There may be ways to write less code, or to combine transpileSync and transpileAsync – but when I did that, it got less readable and feels bloated. Anyway, maybe someone else want have a try?

Test plan

  • Added some tests to verify that initial render.
  • I needed to remove "resetMocks": true, jest config in the package.json so mocking of generateElement was possible, but use the original at the same time.
  • Most of the LiveProvider.test.js test where giving false positives, as the return waitAsync never got called.
  • In order to actually make useEffect work (called) – I changed the jsdom renderer to @testing-library/react.
@tujoworker tujoworker force-pushed the feat/add-ssr-support branch 3 times, most recently from 32c72bf to 6722a9e Compare May 27, 2022 20:55
@tujoworker tujoworker mentioned this pull request May 27, 2022
@tujoworker
Copy link
Author

tujoworker commented Oct 8, 2022

@jpdriver could you review this PR? Or anybody else? 🙏🏻

tujoworker added a commit to tujoworker/react-live that referenced this pull request Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant