import React from 'react'; import { InstantSearchSSRContext } from '../lib/InstantSearchSSRContext'; import type { InitialResults } from 'instantsearch.js'; import type { ReactNode } from 'react'; export type InstantSearchServerState = { initialResults: InitialResults; }; export type InstantSearchSSRProviderProps = Partial & { children?: ReactNode; }; /** * Provider to pass the server state retrieved from `getServerState()` to * . */ export function InstantSearchSSRProvider({ children, ...props }: InstantSearchSSRProviderProps) { // When is mounted, a second provider is used above the user-land // in `getServerState()`. // To avoid the user's provider overriding the context value with an empty object, // we skip this provider. if (Object.keys(props).length === 0) { return <>{children}; } return ( {children} ); }