From 6cdda39025f8b1899a72a022cda169560c69ad8f Mon Sep 17 00:00:00 2001 From: Michael Hogg Date: Fri, 28 Oct 2016 13:00:19 +0100 Subject: [PATCH 1/2] Add experimental support for ReactCSSTransitionGroup --- src/fragment.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/fragment.js b/src/fragment.js index cea4e315..3654dda4 100644 --- a/src/fragment.js +++ b/src/fragment.js @@ -108,7 +108,7 @@ type Props = AbsoluteProps & { parentId?: string }; -const Fragment = (props: Props) => { +const Fragment = (props: Props): ?React$Element => { const { location, matchRoute, @@ -150,5 +150,25 @@ const Fragment = (props: Props) => { return
{children}
; }; -export const AbsoluteFragment = absolute(Fragment); -export const RelativeFragment = relative(Fragment); +type WrappedProps = Props & { + wrapper?: ReactClass // e.g. ReactCSSTransitionGroup +}; + +const WrappedFragment = (props: WrappedProps) => { + if (props.wrapper) { + const Wrapper: ReactClass = props.wrapper; + const fragmentOutput: ?React$Element = Fragment(props); // eslint-disable-line new-cap + return ( + + {fragmentOutput} + + ); + } else { + return ( + + ); + } +}; + +export const AbsoluteFragment = absolute(WrappedFragment); +export const RelativeFragment = relative(WrappedFragment); From 43c9f9716766fd6cabb427a33a4b42b04e960c05 Mon Sep 17 00:00:00 2001 From: Michael Hogg Date: Thu, 8 Dec 2016 11:19:23 +0000 Subject: [PATCH 2/2] WrappedFragment: pass the rest of the props to the Wrapper --- src/fragment.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fragment.js b/src/fragment.js index 3654dda4..f89b14c4 100644 --- a/src/fragment.js +++ b/src/fragment.js @@ -158,8 +158,12 @@ const WrappedFragment = (props: WrappedProps) => { if (props.wrapper) { const Wrapper: ReactClass = props.wrapper; const fragmentOutput: ?React$Element = Fragment(props); // eslint-disable-line new-cap + const { + location, matchRoute, forRoute, withConditions, // eslint-disable-line no-unused-vars + children, parentId, wrapper, ...rest // eslint-disable-line no-unused-vars + } = props; return ( - + {fragmentOutput} );