How to use the react-instantsearch-dom/server.findResultsState function in react-instantsearch-dom

To help you get started, we’ve selected a few react-instantsearch-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algolia / react-instantsearch / examples / ssr / src / server.js View on Github external
server.get('/', async (req, res) => {
  const { App, props } = createApp();

  // URLSync
  const searchState = {
    query: 'iPhone',
    refinementList: {
      brand: ['Apple'],
    },
  };

  const resultsState = await findResultsState(App, {
    ...props,
    searchState,
  });

  const initialState = {
    resultsState,
    searchState,
  };

  const body = ReactDOM.renderToString();

  res.send(
    template({
      title: 'Hello World from the server',
      initialState: JSON.stringify(initialState),
      body,
github algolia / react-instantsearch / examples / next / pages / index.js View on Github external
static async getInitialProps({ asPath }) {
    const searchState = pathToSearchState(asPath);
    const resultsState = await findResultsState(App, {
      ...DEFAULT_PROPS,
      searchState,
    });

    return {
      resultsState,
      searchState,
    };
  }
github algolia / react-instantsearch / examples / server-side-rendering / src / server.js View on Github external
server.get('/', async (_, res) => {
  const { App, props } = createApp();

  const searchState = {
    query: 'iPhone',
    page: 5,
    refinementList: {
      brand: ['Apple'],
    },
  };

  const resultsState = await findResultsState(App, {
    ...props,
    searchState,
  });

  const initialState = {
    searchState,
    resultsState,
  };

  const plainHTML = renderToString();

  res.send(
    template({
      body: plainHTML,
      title: 'Hello World from the server',
      initialState: JSON.stringify(initialState),