Skip to content

Commit

Permalink
fix: harden renderableContext detection (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Mar 22, 2024
1 parent b1285fb commit 7f8f5e6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ export function useContextMap(): ContextMap {
while (node) {
if (node.type && typeof node.type === 'object') {
// https://github.com/facebook/react/pull/28226
const context = 'Provider' in node.type ? node.type : node.type._context
const enableRenderableContext = node.type._context === undefined && node.type.Provider === node.type
const context = enableRenderableContext ? node.type : node.type._context
if (context && context !== FiberContext && !contextMap.has(context)) {
contextMap.set(context, ReactCurrentDispatcher?.current?.readContext(wrapContext(context)))
}
Expand Down

0 comments on commit 7f8f5e6

Please sign in to comment.