NextJs 통합 테스트 - React Context
import { createContext } from "react";
// ToastContext.tsx
// React Context Types
export type ToastStyle = "succeed" | "failed" | "busy";
export type ToastState = {
isShown: boolean;
message: string;
style: ToastStyle;
};
// React Context
export const initialState: ToastState = {
isShown: false,
message: "",
style: "succeed",
};
export const ToastStateContext = createContext(initialState);
export type ToastAction = {
showToast: (state?: Partial<Omit<ToastState, "isShown">>) => void;
hideToast: () => void;
};
export const initialAction: ToastAction = {
showToast: () => {},
hideToast: () => {},
};
export const ToastActionContext = createContext(initialAction);테스트 코드
Last updated