-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update README to use react-router v4 beta
- Loading branch information
Showing
1 changed file
with
14 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,10 @@ Main features | |
|
||
:clock9: Support time traveling in Redux DevTools. | ||
|
||
> Note: | ||
> - `[email protected]` supports new `[email protected]` (with `<Route>` and `<Switch>`) | ||
> - For old `[email protected]` (with `<Match>` and `<Miss>`), you need `[email protected]` | ||
Installation | ||
----------- | ||
Using [npm](https://www.npmjs.com/): | ||
|
@@ -64,15 +68,17 @@ const store = createStore( | |
```js | ||
... | ||
import { Provider } from 'react-redux' | ||
import { Match, Miss } from 'react-router' // react-router v4 | ||
import { Route, Switch } from 'react-router' // react-router v4 | ||
import { ConnectedRouter } from 'connected-react-router' | ||
... | ||
ReactDOM.render( | ||
<Provider store={store}> | ||
<ConnectedRouter history={history}> { /* place ConnectedRouter under Provider */ } | ||
<div> { /* your usual react-router v4 routing */ } | ||
<Match exactly pattern="/" render={() => (<div>Match</div>)} /> | ||
<Miss render={() => (<div>Miss</div>)} /> | ||
<Switch> | ||
<Route exact path="/" render={() => (<div>Match</div>)} /> | ||
<Route render={() => (<div>Miss</div>)} /> | ||
</Switch> | ||
</div> | ||
</ConnectedRouter> | ||
</Provider>, | ||
|
@@ -150,14 +156,16 @@ export default connect(mapStateToProps)(Child) | |
`App.js` | ||
``` js | ||
import React from 'react' | ||
import { Match, Miss } from 'react-router' /* react-router v4 */ | ||
import { Route, Switch } from 'react-router' /* react-router v4 */ | ||
import { ConnectedRouter } from 'connected-react-router' | ||
|
||
const App = ({ history }) => ( /* receive history object via props */ | ||
<ConnectedRouter history={history}> | ||
<div> | ||
<Match exactly pattern="/" render={() => (<div>Match</div>)} /> | ||
<Miss render={() => (<div>Miss</div>)} /> | ||
<Switch> | ||
<Route exact path="/" render={() => (<div>Match</div>)} /> | ||
<Route render={() => (<div>Miss</div>)} /> | ||
</Switch> | ||
</div> | ||
</ConnectedRouter> | ||
) | ||
|