Skip to content
Merged
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
18 changes: 13 additions & 5 deletions docs/guides/NavigatingOutsideOfComponents.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
While you can use `this.props.router` from `withRouter` to navigate around, many apps want to be able to navigate outside of their components. They can do that with the history the app gives to `Router`.

```jsx
// your main file that renders a Router
// Your main file that renders a <Router>:
import { Router, browserHistory } from 'react-router'
import routes from './app/routes'
render(<Router history={browserHistory} routes={routes}/>, el)

render(
<Router history={browserHistory} routes={routes} />,
mountNode
)
```

```jsx
// somewhere like a redux/flux action file:
// Somewhere like a Redux middleware or Flux action:
import { browserHistory } from 'react-router'
browserHistory.push('/some/path') // go to /some/path page
browserHistory.goBack() // go back to previous page

// Go to /some/path.
browserHistory.push('/some/path')

// Go back to previous location.
browserHistory.goBack()
```