Merge pull request #16839 from DanielRosenwasser/routerUnionDuh

Allow 'children' to be an element in react-router.
This commit is contained in:
John Reilly
2017-05-30 11:01:53 +01:00
committed by GitHub
3 changed files with 24 additions and 1 deletions

View File

@@ -65,7 +65,7 @@ export interface RouteProps {
location?: H.Location;
component?: React.SFC<RouteComponentProps<any> | undefined> | React.ComponentClass<RouteComponentProps<any> | undefined>;
render?: ((props: RouteComponentProps<any>) => React.ReactNode);
children?: ((props: RouteComponentProps<any>) => React.ReactNode | React.ReactNode);
children?: ((props: RouteComponentProps<any>) => React.ReactNode) | React.ReactNode;
path?: string;
exact?: boolean;
strict?: boolean;

View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import { Route } from 'react-router';
function RouteWithFunctionChildrenAttribute() {
return <Route path="/" children={() => <div>Hello!</div>} />;
}
function RouteWithFunctionJsxChildren() {
return <Route path="/">
{() => <div>Hello!</div>}
</Route>;
}
function RouteWithElementChildrenAttribute() {
return <Route path="/" children={<div>Hello!</div>} />;
}
function RouteWithElementJsxChildren() {
return <Route path="/">
{<div>Hello!</div>}
</Route>;
}

View File

@@ -18,6 +18,7 @@
"test/Animation.tsx",
"test/Auth.tsx",
"test/Basic.tsx",
"test/Children.tsx",
"test/CustomLink.tsx",
"test/ModalGallery.tsx",
"test/NavigateWithContext.tsx",