const appRoutes: Routes = [
{ path: 'crisis-center',
component: CrisisListComponent
},
{ path: 'hero/:id',
component: HeroDetailComponent
},
{ path: 'heroes',
component: HeroListComponent,
data: { title: 'Heroes List' }
},
{ path: '',
redirectTo: '/heroes',
pathMatch: 'full'
},
{ path: '**',
component: PageNotFoundComponent
}
];
const App = observer(function App() {
return (
<div id="app">
<Switch>
<Route path="/" exact strict component={LandingPage}/>
<Route path="/pricing" component={Pricing}/>
{isSignedIn() && <Route path="/dashboard" component={Dashboard}/>}
{isMobile() && <Route path="/settings" component={MobileSettings}/>}
<Route component={NotFound}/>
</Switch>
</div>
)
})
$ yarn add react-router-dom
# or for iOS/Android
$ yarn add react-router-native
import React from 'react'
# web
import { BrowserRouter as Router } from 'react-router-dom'
# iOS/Android
import { NativeRouter as Router } from 'react-router-native'
const App = function App() {
return (
<Router>
<div id="app">
<p>Your normal application code.</p>
<p>You can add <Route/> components however deep you want.</p>
</div>
</Router>
)
}