Skip to content

Commit 17b6b35

Browse files
committed
create-context: Add displayName to context objects
1 parent 8961a25 commit 17b6b35

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

.changeset/stale-singers-knock.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@radix-ui/react-context': patch
3+
---
4+
5+
Add `displayName` to context objects

packages/react/context/src/create-context.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function createContext<ContextValueType extends object | null>(
55
defaultContext?: ContextValueType
66
) {
77
const Context = React.createContext<ContextValueType | undefined>(defaultContext);
8+
Context.displayName = rootComponentName + 'Context';
89

910
const Provider: React.FC<ContextValueType & { children: React.ReactNode }> = (props) => {
1011
const { children, ...context } = props;
@@ -50,6 +51,7 @@ function createContextScope(scopeName: string, createContextScopeDeps: CreateSco
5051
defaultContext?: ContextValueType
5152
) {
5253
const BaseContext = React.createContext<ContextValueType | undefined>(defaultContext);
54+
BaseContext.displayName = rootComponentName + 'Context';
5355
const index = defaultContexts.length;
5456
defaultContexts = [...defaultContexts, defaultContext];
5557

0 commit comments

Comments
 (0)