Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

fix(hooks): mount widgets in SSR to retrieve HTML #3518

Merged
merged 4 commits into from
Jun 15, 2022

Conversation

francoischalifour
Copy link
Member

@francoischalifour francoischalifour commented Jun 14, 2022

This fixes our SSR APIs as reported in #3511.

During the useSyncExternalStore() migration in #3489, we omitted some SSR checks by removing the serverState.initialResults condition. This was responsible for mounting the widgets during rendering, to then render them on the server. We now also cover the generated HTML with a test.

Note that this solution doesn't work with Strict Mode, as it wasn't prior to the bug. This is just a fix to release early, and then we'll work on Strict Mode support.

Closes #3511

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 14, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d81a7d5:

Sandbox Source
algolia/create-instantsearch-app Configuration
hooks-example Configuration
hooks-next-example Issue #3511

@netlify
Copy link

netlify bot commented Jun 14, 2022

Deploy Preview for react-instantsearch ready!

Name Link
🔨 Latest commit d81a7d5
🔍 Latest deploy log https://app.netlify.com/sites/react-instantsearch/deploys/62a8b32e4f03800008b08c6f
😎 Deploy Preview https://deploy-preview-3518--react-instantsearch.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@francoischalifour francoischalifour merged commit aa5f9d8 into master Jun 15, 2022
@francoischalifour francoischalifour deleted the fix/hooks-server-state-html branch June 15, 2022 08:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

React Instantsearch Hooks: SSR not working on v6.27.0
2 participants