-
Notifications
You must be signed in to change notification settings - Fork 555
Description
🐛 Current behavior
At the moment I'm experiencing issues with the useRelatedProducts hook provided by react-instantsearch, specifically in an SSR setup.
At the moment, whenever components which use the useRelatedProducts hook are served by the server along with Algolia server state an hydration error occurs. On closer inspection it seems like the internal state of the hook does not seem to be stable. At the first render it will contain the results as provided by the server to the InstantSearchSSRProvider, however on re-render it will be empty, causing hydration issues.
🔍 Steps to reproduce
- Clone my repository which is linked below.
- Install dependencies:
nvm use && corepack enable && pnpm install - Run the client-only build using
pnpm start-client, which should work as intended. - Run the SSR build using
pnpm start-server, which should throw hydration errors.
See the project README for a more detailed description.
Live reproduction
https://github.com/daanjo3/algolia-recommendations-ssr
💭 Expected behavior
I would expect the state (and thus the resulting items field) of the useRelatedProducts hook to remain stable across re-renders, as long as no dependencies change.
Package version
algoliasearch 5.41.0, instantsearch.js 4.81.0, react-instantsearch 7.17.0, react 18.3.1, react-dom 18.3.1
Operating system
Arch Linux, MacOS
Browser
Mozilla Firefox 144.0.2, Google Chrome 141.0.7390.107
Code of Conduct
- I agree to follow this project's Code of Conduct