Skip to content

Commit

Permalink
refactor: remove UPDATE_CLIENT_CTX
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStack committed Jul 21, 2024
1 parent 88aa5e2 commit 04654ce
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/hooks/useClientContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@ import React, {

export const OUTSIDE_CLIENT_PROVIDER_ERROR =
'Cannot be used outside ClientProvider!';

export interface UpdateClientCtxType<T> {
updateClientCtx: (props: Partial<T>) => void;
}

const UPDATE_CLIENT_CTX = {
updateClientCtx: () => {
throw new Error(OUTSIDE_CLIENT_PROVIDER_ERROR);
},
};

export const ClientContext = createContext<unknown | undefined>(undefined);

export const useClientContext = <T,>(): T & UpdateClientCtxType<T> => {
Expand Down Expand Up @@ -58,7 +53,9 @@ export const ClientProvider = <T,>({
const [contextValue, setContextValue] = useState({
...defaultValue,
...value,
...UPDATE_CLIENT_CTX,
updateClientCtx: (_: Partial<T>): void => {
throw new Error(OUTSIDE_CLIENT_PROVIDER_ERROR);
},
});

const updateContext = useCallback(
Expand Down

0 comments on commit 04654ce

Please sign in to comment.