refactor: provider 레이어 변경 & 누락된 public api 수정
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"use client";
|
||||
|
||||
import { createContext } from "react";
|
||||
import { getCookie, setCookie, removeCookie } from "./cookie";
|
||||
|
||||
export interface CookieContextType {
|
||||
getCookie: (name: string) => string | undefined;
|
||||
setCookie: (
|
||||
name: string,
|
||||
value: string,
|
||||
options: Cookies.CookieAttributes,
|
||||
) => void;
|
||||
removeCookie: (name: string, options: Cookies.CookieAttributes) => void;
|
||||
}
|
||||
|
||||
export const CookieContext = createContext<CookieContextType | null>(null);
|
||||
|
||||
export function CookieProvider({ children }: { children: React.ReactNode }) {
|
||||
const cookieContextValue: CookieContextType = {
|
||||
getCookie,
|
||||
setCookie,
|
||||
removeCookie,
|
||||
};
|
||||
|
||||
return (
|
||||
<CookieContext.Provider value={cookieContextValue}>
|
||||
{children}
|
||||
</CookieContext.Provider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export { CookieProvider } from "./cookie-provider";
|
||||
export { getCookie, setCookie, removeCookie } from "./cookie";
|
||||
Reference in New Issue
Block a user