Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/connectWithShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,23 @@ function wrapWithShellContext<S, OP, SP, DP>(
}
}

const ChildWithContext: React.FunctionComponent<any> = props => {
return (
<ShellContext.Provider value={props.originalShell}>
<>
{React.Children.map(props.children, child =>
child ? React.cloneElement(child, _.omit(props, ['children', 'originalShell'])) : child
)}
</>
</ShellContext.Provider>
)
}

const wrapChildrenIfNeeded = (props: WithChildren<OP>, originalShell: Shell): WithChildren<OP> =>
props.children
? {
...props,
children: <ShellContext.Provider value={originalShell}>{props.children}</ShellContext.Provider>
children: <ChildWithContext originalShell={originalShell}>{props.children}</ChildWithContext>
}
: props

Expand Down