From 8fd1e36dc64840c096aa0acf75b99808291fce4d Mon Sep 17 00:00:00 2001 From: Andrew Dyomin Date: Tue, 29 Sep 2020 14:03:22 +0300 Subject: [PATCH] propagate props to children components in connectWithShell --- src/connectWithShell.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/connectWithShell.tsx b/src/connectWithShell.tsx index 062b692f..970461e5 100644 --- a/src/connectWithShell.tsx +++ b/src/connectWithShell.tsx @@ -91,11 +91,23 @@ function wrapWithShellContext( } } + const ChildWithContext: React.FunctionComponent = props => { + return ( + + <> + {React.Children.map(props.children, child => + child ? React.cloneElement(child, _.omit(props, ['children', 'originalShell'])) : child + )} + + + ) + } + const wrapChildrenIfNeeded = (props: WithChildren, originalShell: Shell): WithChildren => props.children ? { ...props, - children: {props.children} + children: {props.children} } : props