algolia / react-instantsearch

⚡️ Lightning-fast search for React and React Native applications, by Algolia.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/
MIT License
1.97k stars 386 forks source link

React InstantSearchSSRProvider hooks - Gatsby SSG #3674

Closed Lium-7768 closed 1 year ago

Lium-7768 commented 1 year ago

🐛 Bug description

I'm trying to implement algolia with Gatsby SSG functionality into our platform via a POC.

🔍 Bug reproduction

Steps to reproduce the behavior:

  1. Get data through xml, and then call serverdata is the default value of InstantSearchSSRProvider, the hook has no initialized data, and the ui will not change.
  2. The InstantSearchSSRProvider component cannot implement the Gatsby SSG function without passing in the default value

Live reproduction:

https://codesandbox.io/p/github/Lium-Yu/gatsby-algolia/main?file=%2Fsrc%2Fpages%2Findex.js

github 🌰

💭 Expected behavior

InstantSSRProvider should be able to give initial value, or give me other solutions, thanks.

🖥 Screenshots

image

image

Environment

image

FabienMotte commented 1 year ago

We're doing a round of cleanup before migrating this repository to the new InstantSearch monorepo, so we're going to close it.

You can use the prop initialResults on the widget <InstantSearchSSRProvider> to forward the initial results to <InstantSearch>. The initialResults object shape should correspond to what's returned by the getServerState() function.