diff --git a/src/fragment.js b/src/fragment.js index cea4e315..f89b14c4 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,29 @@ 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 + const { + location, matchRoute, forRoute, withConditions, // eslint-disable-line no-unused-vars + children, parentId, wrapper, ...rest // eslint-disable-line no-unused-vars + } = props; + return ( + + {fragmentOutput} + + ); + } else { + return ( + + ); + } +}; + +export const AbsoluteFragment = absolute(WrappedFragment); +export const RelativeFragment = relative(WrappedFragment);