-
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.
Merge pull request #28 from supasate/support-react-router-v4-beta
Support [email protected]
- Loading branch information
Showing
9 changed files
with
652 additions
and
689 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> | ||
) | ||
|
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
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
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
Oops, something went wrong.