mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
updated test and component prop of router
This commit is contained in:
Vendored
+2
-3
@@ -48,12 +48,11 @@ declare module 'react-router' {
|
||||
history: H.History;
|
||||
}
|
||||
|
||||
interface PartialRouteComponentProps<P> extends Partial<RouteComponentProps<P>> {
|
||||
}
|
||||
interface PartialRouteComponentProps<P> extends Partial<RouteComponentProps<P>> {}
|
||||
|
||||
interface RouteProps {
|
||||
location?: H.Location;
|
||||
component?: React.SFC<PartialRouteComponentProps<any> | void> | React.ComponentClass<PartialRouteComponentProps<any> | void>;
|
||||
component?: React.SFC<RouteComponentProps<any> | void> | React.ComponentClass<RouteComponentProps<any> | void>;
|
||||
render?: (props: RouteComponentProps<any>) => React.ReactNode;
|
||||
children?: (props: RouteComponentProps<any>) => React.ReactNode | React.ReactNode;
|
||||
path?: string;
|
||||
|
||||
@@ -19,15 +19,22 @@ const find = (id: number) => PEEPS.find(p => p.id == id)
|
||||
|
||||
const RecursiveExample = () => (
|
||||
<Router>
|
||||
<Person match={{ params: { id: 0 }, url: '', path: '', isExact: true }} />
|
||||
<Person match={{ params: { id: 0 }, url: '' }}/>
|
||||
</Router>
|
||||
)
|
||||
|
||||
interface PersonProps extends Partial<RouteComponentProps<{id: number}>> {
|
||||
match: match<{id: number}>;
|
||||
interface InitialPersonProps {
|
||||
match: {
|
||||
params: {
|
||||
id: number;
|
||||
};
|
||||
url: string;
|
||||
};
|
||||
}
|
||||
|
||||
const Person: React.SFC<PersonProps> = ({ match }) => {
|
||||
type PersonProps = RouteComponentProps<{ id: number }>;
|
||||
|
||||
const Person: React.SFC<InitialPersonProps | PersonProps> = ({ match }) => {
|
||||
const person = find(match.params.id)
|
||||
|
||||
return (
|
||||
@@ -42,9 +49,9 @@ const Person: React.SFC<PersonProps> = ({ match }) => {
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Route path={`${match.url}/:id`} component={Person}/>
|
||||
<Route path={`${match.url}/:id`} component={Person as React.SFC<PersonProps>}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default RecursiveExample
|
||||
export default RecursiveExample
|
||||
|
||||
Reference in New Issue
Block a user