Open History to see the last commit
1import { useEffect } from 'octane';
2import { QueryClientContext } from './context.ts';
3import type { OctaneNode } from 'octane';
4import type { QueryClient } from '@tanstack/query-core';
5β
6type QueryClientProviderProps = {
7 client: QueryClient;
8 children?: OctaneNode;
9};
10β
11// QueryClientProvider β provides the QueryClient via context and mounts/unmounts
12// it with the component. It's authored in .tsrx because it's a COMPONENT that
13// renders a context Provider with children + a mount effect, which only the
14// octane compiler can emit (the binding's hooks stay plain TS).
15export function QueryClientProvider(props: QueryClientProviderProps) @{
16 useEffect(() => {
17 props.client.mount();
18 return () => {
19 props.client.unmount();
20 };
21 }, [props.client]);
22 <QueryClientContext.Provider value={props.client}>{props.children}</QueryClientContext.Provider>
23}