Skip to content
This repository was archived by the owner on Dec 15, 2018. It is now read-only.
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
30 changes: 27 additions & 3 deletions src/fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ type Props = AbsoluteProps & {
parentId?: string
};

const Fragment = (props: Props) => {
const Fragment = (props: Props): ?React$Element<any> => {
const {
location,
matchRoute,
Expand Down Expand Up @@ -150,5 +150,29 @@ const Fragment = (props: Props) => {
return <div>{children}</div>;
};

export const AbsoluteFragment = absolute(Fragment);
export const RelativeFragment = relative(Fragment);
type WrappedProps = Props & {
wrapper?: ReactClass<any> // e.g. ReactCSSTransitionGroup
};

const WrappedFragment = (props: WrappedProps) => {
if (props.wrapper) {
const Wrapper: ReactClass<any> = props.wrapper;
const fragmentOutput: ?React$Element<any> = 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 (
<Wrapper {...rest}>
{fragmentOutput}
</Wrapper>
);
} else {
return (
<Fragment {...props} />
);
}
};

export const AbsoluteFragment = absolute(WrappedFragment);
export const RelativeFragment = relative(WrappedFragment);