Skip to content

Commit

Permalink
Merge pull request #28 from supasate/support-react-router-v4-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
supasate authored Jan 30, 2017
2 parents d8ad326 + 1ba1400 commit 9d936a1
Show file tree
Hide file tree
Showing 9 changed files with 652 additions and 689 deletions.
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/):
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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>
)
Expand Down
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"react": "^15.4.1",
"react-dom": "^15.4.1",
"react-redux": "^4.4.6",
"react-router": "^4.0.0-alpha.6",
"react-router": "^4.0.0-beta.2",
"redux": "^3.6.0"
}
}
2 changes: 1 addition & 1 deletion examples/src/components/NavBar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Link } from 'react-router'
import { Link } from 'react-router-dom'

const NavBar = () => (
<div>
Expand Down
12 changes: 7 additions & 5 deletions examples/src/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Match, Miss } from 'react-router'
import { Route, Switch } from 'react-router'
import Home from '../components/Home'
import Hello from '../components/Hello'
import Counter from '../components/Counter'
Expand All @@ -9,10 +9,12 @@ import NavBar from '../components/NavBar'
const routes = (
<div>
<NavBar />
<Match exactly pattern="/" component={Home} />
<Match pattern="/hello" component={Hello} />
<Match pattern="/counter" component={Counter} />
<Miss component={NoMatch} />
<Switch>
<Route exact path="/" component={Home} />
<Route path="/hello" component={Hello} />
<Route path="/counter" component={Counter} />
<Route component={NoMatch} />
</Switch>
</div>
)

Expand Down
Loading

0 comments on commit 9d936a1

Please sign in to comment.