Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update decoupling UI from URL pattern #3178

Merged
merged 1 commit into from
Mar 11, 2016
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion docs/guides/IndexRoutes.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ that redirects the user. You would set this up with plain routes as:

```js
const routes = [{
path: '/', component: App,
path: '/',
component: App,
indexRoute: { onEnter: (nextState, replace) => replace('/welcome') },
childRoutes: [
{ path: 'welcome', component: Welcome },
Expand Down
58 changes: 31 additions & 27 deletions docs/guides/RouteConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ render((
<Route path="/" component={App}>
<IndexRoute component={Dashboard} />
<Route path="about" component={About} />
<Route path="inbox" component={Inbox}>
{/* Use /messages/:id instead of messages/:id */}
<Route path="/messages/:id" component={Message} />

{/* Use /messages/:id instead of /inbox/messages/:id */}
<Route component={Inbox}>
<Route path="inbox" />
<Route path="messages/:id" component={Message} />
</Route>
</Route>
</Router>
Expand Down Expand Up @@ -150,12 +152,13 @@ render((
<Route path="/" component={App}>
<IndexRoute component={Dashboard} />
<Route path="about" component={About} />
<Route path="inbox" component={Inbox}>
<Route path="/messages/:id" component={Message} />

{/* Redirect /inbox/messages/:id to /messages/:id */}
<Redirect from="messages/:id" to="/messages/:id" />
<Route component={Inbox}>
<Route path="inbox" />
<Route path="messages/:id" component={Message} />
</Route>

{/* Redirect /inbox/messages/:id to /messages/:id */}
<Redirect from="inbox/messages/:id" to="/messages/:id" />
</Route>
</Router>
), document.body)
Expand Down Expand Up @@ -184,26 +187,27 @@ The `<Redirect>` configuration helper is not available when using plain routes,
The route config we've discussed up to this point could also be specified like this:

```js
const routes = [
{ path: '/',
component: App,
indexRoute: { component: Dashboard },
childRoutes: [
{ path: 'about', component: About },
{ path: 'inbox',
component: Inbox,
childRoutes: [
{ path: '/messages/:id', component: Message },
{ path: 'messages/:id',
onEnter: function (nextState, replace) {
replace('/messages/' + nextState.params.id)
}
}
]
const routes = {
path: '/',
component: App,
indexRoute: { component: Dashboard },
childRoutes: [
{ path: 'about', component: About },
{
component: Inbox,
childRoutes: [
{ path: 'inbox' },
{ path: 'messages/:id', component: Message }
]
},
{
path: 'inbox/messages/:id',
onEnter: (nextState, replace) => {
replace('/messages/' + nextState.params.id)
}
]
}
]
}
]
}

render(<Router routes={routes} />, document.body)
```