From da8ab8d464370a5f220119f732e4bff5ca1a27ce Mon Sep 17 00:00:00 2001 From: wo-o29 Date: Mon, 15 Sep 2025 19:53:51 +0900 Subject: [PATCH 1/3] docs: Update buildContext function signature and example default values --- src/utils/buildContext/buildContext.md | 4 ++-- src/utils/buildContext/ko/buildContext.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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/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() { From ecb295db4de55393c6e4a01577bfdaf32b8cf53f Mon Sep 17 00:00:00 2001 From: wo-o29 Date: Mon, 15 Sep 2025 19:54:16 +0900 Subject: [PATCH 2/3] fix: Change context default value type from undefined to null in buildContext --- src/utils/buildContext/buildContext.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/buildContext/buildContext.tsx b/src/utils/buildContext/buildContext.tsx index 59fe57ea..5015cccd 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( @@ -48,11 +48,11 @@ export function buildContext( function useInnerContext() { const context = useContext(Context); - if (context != null) { + if (context !== null) { return context; } - if (defaultContextValues != null) { + if (defaultContextValues !== undefined) { return defaultContextValues; } From a98922cf4dd8d5671ca110300f408d5d74f929ff Mon Sep 17 00:00:00 2001 From: wo-o29 Date: Mon, 15 Sep 2025 19:55:08 +0900 Subject: [PATCH 3/3] fix: Add displayName to Provider for better debugging --- src/utils/buildContext/buildContext.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/buildContext/buildContext.tsx b/src/utils/buildContext/buildContext.tsx index 5015cccd..f6b3cb58 100644 --- a/src/utils/buildContext/buildContext.tsx +++ b/src/utils/buildContext/buildContext.tsx @@ -45,6 +45,8 @@ export function buildContext( return {children}; } + Object.assign(Provider, { displayName: `${contextName}Provider` }); + function useInnerContext() { const context = useContext(Context);