import * as React from 'react'
import {
BrowserRouter as Router,
RouteComponentProps,
Route,
Link,
match
} from 'react-router-dom'
import * as H from 'history';
const PEEPS = [
{ id: 0, name: 'Michelle', friends: [ 1, 2, 3 ] },
{ id: 1, name: 'Sean', friends: [ 0, 3 ] },
{ id: 2, name: 'Kim', friends: [ 0, 1, 3 ], },
{ id: 3, name: 'David', friends: [ 1, 2 ] }
]
const find = (id: number) => PEEPS.find(p => p.id == id)
const RecursiveExample = () => (
)
interface PersonProps extends Partial> {
match: match<{id: number}>;
}
const Person: React.SFC = ({ match }) => {
const person = find(match.params.id)
return (
{person!.name}’s Friends
{person!.friends.map(id => (
-
{find(id)!.name}
))}
)
}
export default RecursiveExample