Skip to content

Commit

Permalink
feat(CookiesProvider): remove extra cache
Browse files Browse the repository at this point in the history
  • Loading branch information
asabotovich committed Aug 21, 2023
1 parent 3794962 commit 8b7603f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/hooks/useCookies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ export const CookiesProvider: FC<{
children: ReactNode;
serverSideCookies: GetServerSidePropsContext['req']['cookies'];
}> = ({ serverSideCookies, children }) => {
const cookies = useMemo(() => {
return isServer() ? serverSideCookies : parseClientCookies();
}, [serverSideCookies]);
const getCookie = useCallback(
(name: string) => {
const cookies = isServer() ? serverSideCookies : parseClientCookies();

const getCookie = useCallback((name: string) => cookies[name] ?? null, [cookies]);
return cookies[name] ?? null;
},
[serverSideCookies],
);

const value = useMemo(
() => ({
Expand Down

0 comments on commit 8b7603f

Please sign in to comment.