Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Apr 25, 2024
1 parent 063ddcc commit d849a91
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,17 @@ export function useContextBridge(): ContextBridge {
const contextMap = useContextMap()

// Flatten context and their memoized values into a `ContextBridge` provider
return React.useMemo<ContextBridge>(
return React.useMemo(
() =>
({ children }) => {
for (const [context, value] of contextMap) {
children = <context.Provider value={value}>{children}</context.Provider>
}
return children as unknown as JSX.Element
},
Array.from(contextMap.keys()).reduce(
(Prev, context) => (props) =>
(
<Prev>
<context.Provider {...props} value={contextMap.get(context)} />
</Prev>
),
(props) => <FiberProvider {...props} />,
),
[contextMap],
)
}

0 comments on commit d849a91

Please sign in to comment.