diff --git a/src/utils/buildContext/buildContext.md b/src/utils/buildContext/buildContext.md index 2dab9435..8174cbee 100644 --- a/src/utils/buildContext/buildContext.md +++ b/src/utils/buildContext/buildContext.md @@ -5,7 +5,7 @@ ## Interface ```ts -function buildContext( +function buildContext( contextName: string, defaultContextValues: ContextValuesType ): [ @@ -54,7 +54,7 @@ function buildContext( ```tsx const [Provider, useContext] = buildContext<{ title: string }>( 'TestContext', - null + { title: "" }, ); function Inner() { diff --git a/src/utils/buildContext/buildContext.tsx b/src/utils/buildContext/buildContext.tsx index 59fe57ea..f6b3cb58 100644 --- a/src/utils/buildContext/buildContext.tsx +++ b/src/utils/buildContext/buildContext.tsx @@ -33,7 +33,7 @@ export function buildContext( contextName: string, defaultContextValues?: ContextValuesType ) { - const Context = createContext(defaultContextValues ?? undefined); + const Context = createContext(defaultContextValues ?? null); function Provider({ children, ...contextValues }: ProviderProps) { const value = useMemo( @@ -45,14 +45,16 @@ export function buildContext( return {children}; } + Object.assign(Provider, { displayName: `${contextName}Provider` }); + function useInnerContext() { const context = useContext(Context); - if (context != null) { + if (context !== null) { return context; } - if (defaultContextValues != null) { + if (defaultContextValues !== undefined) { return defaultContextValues; } diff --git a/src/utils/buildContext/ko/buildContext.md b/src/utils/buildContext/ko/buildContext.md index e5f41955..ac259ab2 100644 --- a/src/utils/buildContext/ko/buildContext.md +++ b/src/utils/buildContext/ko/buildContext.md @@ -5,7 +5,7 @@ ## 인터페이스 ```ts -function buildContext( +function buildContext( contextName: string, defaultContextValues: ContextValuesType ): [ @@ -54,7 +54,7 @@ function buildContext( ```tsx const [Provider, useContext] = buildContext<{ title: string }>( 'TestContext', - null + { title: "" }, ); function Inner() {