Skip to content

Commit 0e0b0b0

Browse files
committed
fix: change back accidental change to context generation and props spread
1 parent ea13aa4 commit 0e0b0b0

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/context-file.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export class ContextFile extends ModuleBuilder {
4242
yield `let currentContext: ${contextPropsName} | undefined;`;
4343
yield ``;
4444

45-
yield `export const ${providerName}: ${FC()}<${PropsWithChildren()}<${contextPropsName}>> = ({ children, fetch, options }) => {`;
46-
yield ` const value = ${useMemo()}(() => ({ fetch, options }), [fetch, options.mapUnhandledException, options.mapValidationError, options.root]);`;
45+
yield `export const ${providerName}: ${FC()}<${PropsWithChildren()}<${contextPropsName}>> = ({ children, ...props }) => {`;
46+
yield ` const value = ${useMemo()}(() => ({ ...props }), [props.fetch, props.mapUnhandledException, props.mapValidationError, props.root]);`;
4747
yield ` currentContext = value;`;
4848
yield ` return <${contextName}.Provider value={value}>{children}</${contextName}.Provider>;`;
4949
yield `};`;
@@ -66,7 +66,7 @@ export class ContextFile extends ModuleBuilder {
6666
interfaceName,
6767
)} = new ${this.client.fn(
6868
className,
69-
)}(currentContext.fetch, currentContext.options);`;
69+
)}(currentContext.fetch ?? window.fetch.bind(window), currentContext);`;
7070
yield ` return ${localName};`;
7171
yield `};`;
7272

src/snapshot/v1/hooks/context.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ let currentContext: BasketryExampleContextProps | undefined;
4545

4646
export const BasketryExampleProvider: FC<
4747
PropsWithChildren<BasketryExampleContextProps>
48-
> = ({ children, fetch, options }) => {
48+
> = ({ children, ...props }) => {
4949
const value = useMemo(
50-
() => ({ fetch, options }),
50+
() => ({ ...props }),
5151
[
52-
fetch,
53-
options.mapUnhandledException,
54-
options.mapValidationError,
55-
options.root,
52+
props.fetch,
53+
props.mapUnhandledException,
54+
props.mapValidationError,
55+
props.root,
5656
],
5757
);
5858
currentContext = value;
@@ -71,8 +71,8 @@ export const getAuthPermutationService = () => {
7171
}
7272
const authPermutationService: AuthPermutationService =
7373
new HttpAuthPermutationService(
74-
currentContext.fetch,
75-
currentContext.options,
74+
currentContext.fetch ?? window.fetch.bind(window),
75+
currentContext,
7676
);
7777
return authPermutationService;
7878
};
@@ -99,8 +99,8 @@ export const getExhaustiveService = () => {
9999
);
100100
}
101101
const exhaustiveService: ExhaustiveService = new HttpExhaustiveService(
102-
currentContext.fetch,
103-
currentContext.options,
102+
currentContext.fetch ?? window.fetch.bind(window),
103+
currentContext,
104104
);
105105
return exhaustiveService;
106106
};
@@ -126,8 +126,8 @@ export const getGizmoService = () => {
126126
);
127127
}
128128
const gizmoService: GizmoService = new HttpGizmoService(
129-
currentContext.fetch,
130-
currentContext.options,
129+
currentContext.fetch ?? window.fetch.bind(window),
130+
currentContext,
131131
);
132132
return gizmoService;
133133
};
@@ -153,8 +153,8 @@ export const getWidgetService = () => {
153153
);
154154
}
155155
const widgetService: WidgetService = new HttpWidgetService(
156-
currentContext.fetch,
157-
currentContext.options,
156+
currentContext.fetch ?? window.fetch.bind(window),
157+
currentContext,
158158
);
159159
return widgetService;
160160
};

0 commit comments

Comments
 (0)