Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Apr 9, 2024
1 parent 280c65d commit dad6b5c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ export function useNearestParent<T = any>(
return parentRef
}

/**
* Represents a map of all live contexts.
*/
export type ContextMap = Map<Context<any>, any> & {
get<T>(context: Context<T>): T | undefined
}
Expand Down Expand Up @@ -200,13 +203,13 @@ export function useContextBridge(): ContextBridge {
const contextMap = useContextMap()

// Flatten context and their memoized values into a `ContextBridge` provider
return useMemo(
return useMemo<ContextBridge>(
() =>
({ children }) => {
for (const [context, value] of contextMap) {
children = createElement(context.Provider, { value }, children)
}
return children as any
return children as unknown as JSX.Element
},
[contextMap],
)
Expand Down

0 comments on commit dad6b5c

Please sign in to comment.