{"version":3,"file":"HydrationBoundary.mjs","sources":["../../../src/react/HydrationBoundary.ts"],"sourcesContent":["import * as React from 'react'\n\nimport { HydrateOptions, QueryClient, hydrate } from '../vanilla'\nimport { useQueryClient } from './QueryClientProvider'\n\nexport interface HydrationBoundaryProps {\n  state?: unknown\n  options?: HydrateOptions\n  children?: React.ReactNode\n  queryClient?: QueryClient\n}\n\nexport const HydrationBoundary = ({\n  children,\n  options = {},\n  state,\n  queryClient,\n}: HydrationBoundaryProps) => {\n  const client = useQueryClient(queryClient)\n\n  const optionsRef = React.useRef(options)\n  optionsRef.current = options\n\n  // Running hydrate again with the same queries is safe,\n  // it wont overwrite or initialize existing queries,\n  // relying on useMemo here is only a performance optimization.\n  // hydrate can and should be run *during* render here for SSR to work properly\n  React.useMemo(() => {\n    if (state) {\n      hydrate(client, state, optionsRef.current)\n    }\n  }, [client, state])\n\n  return children as React.ReactElement\n}\n"],"names":["HydrationBoundary","children","options","state","queryClient","client","useQueryClient","optionsRef","React","useRef","current","useMemo","hydrate"],"mappings":";;;;AAYO,MAAMA,iBAAiB,GAAGA,CAAC;EAChCC,QAAQ;EACRC,OAAO,GAAG,EAAE;EACZC,KAAK;AACLC,EAAAA,WAAAA;AACsB,CAAC,KAAK;AAC5B,EAAA,MAAMC,MAAM,GAAGC,cAAc,CAACF,WAAW,CAAC,CAAA;AAE1C,EAAA,MAAMG,UAAU,GAAGC,KAAK,CAACC,MAAM,CAACP,OAAO,CAAC,CAAA;EACxCK,UAAU,CAACG,OAAO,GAAGR,OAAO,CAAA;;AAE5B;AACA;AACA;AACA;EACAM,KAAK,CAACG,OAAO,CAAC,MAAM;AAClB,IAAA,IAAIR,KAAK,EAAE;MACTS,OAAO,CAACP,MAAM,EAAEF,KAAK,EAAEI,UAAU,CAACG,OAAO,CAAC,CAAA;AAC5C,KAAA;AACF,GAAC,EAAE,CAACL,MAAM,EAAEF,KAAK,CAAC,CAAC,CAAA;AAEnB,EAAA,OAAOF,QAAQ,CAAA;AACjB;;;;"}