Skip to content

Commit 04654ce

Browse files
committed
refactor: remove UPDATE_CLIENT_CTX
1 parent 88aa5e2 commit 04654ce

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/hooks/useClientContext.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@ import React, {
1616

1717
export const OUTSIDE_CLIENT_PROVIDER_ERROR =
1818
'Cannot be used outside ClientProvider!';
19+
1920
export interface UpdateClientCtxType<T> {
2021
updateClientCtx: (props: Partial<T>) => void;
2122
}
2223

23-
const UPDATE_CLIENT_CTX = {
24-
updateClientCtx: () => {
25-
throw new Error(OUTSIDE_CLIENT_PROVIDER_ERROR);
26-
},
27-
};
28-
2924
export const ClientContext = createContext<unknown | undefined>(undefined);
3025

3126
export const useClientContext = <T,>(): T & UpdateClientCtxType<T> => {
@@ -58,7 +53,9 @@ export const ClientProvider = <T,>({
5853
const [contextValue, setContextValue] = useState({
5954
...defaultValue,
6055
...value,
61-
...UPDATE_CLIENT_CTX,
56+
updateClientCtx: (_: Partial<T>): void => {
57+
throw new Error(OUTSIDE_CLIENT_PROVIDER_ERROR);
58+
},
6259
});
6360

6461
const updateContext = useCallback(

0 commit comments

Comments
 (0)