Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 66x 66x 66x | import type { ReactNode } from "react";
import { Provider as JotaiProvider } from "jotai";
import { useHydrateAtoms } from "jotai/utils";
// Using any keeps hydration usable across atom shapes in tests.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type InitialValues = Array<readonly [any, any]>;
function HydrateAtoms({
initialValues,
children,
}: {
initialValues: InitialValues;
children: ReactNode;
}) {
useHydrateAtoms(initialValues);
return children;
}
function JotaiTestProvider({
initialValues = [],
children,
}: {
initialValues?: InitialValues;
children: ReactNode;
}) {
return (
<JotaiProvider>
<HydrateAtoms initialValues={initialValues}>{children}</HydrateAtoms>
</JotaiProvider>
);
}
export default JotaiTestProvider;
|