Skip to content

Commit

Permalink
Add support for react-router@5.0.0 (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmfcmf authored and supasate committed Apr 14, 2019
1 parent 1743d23 commit d327b90
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 48 deletions.
2 changes: 1 addition & 1 deletion FAQ.md
Expand Up @@ -123,7 +123,7 @@ const history = createMemoryHistory({
`App.js`
``` js
import React from 'react'
import { Route, Switch } from 'react-router' /* react-router v4 */
import { Route, Switch } from 'react-router' /* react-router v4/v5 */
import { ConnectedRouter } from 'connected-react-router'

const App = ({ history }) => ( /* receive history object via props */
Expand Down
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -4,13 +4,13 @@
Connected React Router [![Build Status](https://travis-ci.org/supasate/connected-react-router.svg?branch=master)](https://travis-ci.org/supasate/connected-react-router) [![Open Source Helpers](https://www.codetriage.com/supasate/connected-react-router/badges/users.svg)](https://www.codetriage.com/supasate/connected-react-router)
======================
A Redux binding for React Router v4
A Redux binding for React Router v4 and v5

Main features
-------------
:sparkles: Synchronize router state with redux store through uni-directional flow (i.e. history -> store -> router -> components).

:gift: Support [React Router v4](https://github.com/ReactTraining/react-router).
:gift: Support [React Router v4 and v5](https://github.com/ReactTraining/react-router).

:sunny: Support functional component hot reloading while preserving state (with [react-hot-reload](https://github.com/gaearon/react-hot-loader)).

Expand Down Expand Up @@ -90,14 +90,14 @@ export default function configureStore(preloadedState) {

### Step 3

- Wrap your react-router v4 routing with `ConnectedRouter` and pass the `history` object as a prop. Remember to delete any usage of `BrowserRouter` or `NativeRouter` as leaving this in will [cause](https://github.com/supasate/connected-react-router/issues/230#issuecomment-461628073) [problems](https://github.com/supasate/connected-react-router/issues/230#issuecomment-476164384) synchronising the state.
- Wrap your react-router v4/v5 routing with `ConnectedRouter` and pass the `history` object as a prop. Remember to delete any usage of `BrowserRouter` or `NativeRouter` as leaving this in will [cause](https://github.com/supasate/connected-react-router/issues/230#issuecomment-461628073) [problems](https://github.com/supasate/connected-react-router/issues/230#issuecomment-476164384) synchronising the state.
- Place `ConnectedRouter` as a child of `react-redux`'s `Provider`.

```js
// index.js
...
import { Provider } from 'react-redux'
import { Route, Switch } from 'react-router' // react-router v4
import { Route, Switch } from 'react-router' // react-router v4/v5
import { ConnectedRouter } from 'connected-react-router'
import configureStore, { history } from './configureStore'
...
Expand All @@ -106,7 +106,7 @@ const store = configureStore(/* provide initial state if any */)
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}> { /* place ConnectedRouter under Provider */ }
<> { /* your usual react-router v4 routing */ }
<> { /* your usual react-router v4/v5 routing */ }
<Switch>
<Route exact path="/" render={() => (<div>Match</div>)} />
<Route render={() => (<div>Miss</div>)} />
Expand Down
6 changes: 3 additions & 3 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "connected-react-router",
"version": "6.3.2",
"description": "A Redux binding for React Router v4",
"description": "A Redux binding for React Router v4 and v5",
"main": "lib/index.js",
"module": "esm/index.js",
"types": "./index.d.ts",
Expand Down Expand Up @@ -36,7 +36,7 @@
"prop-types": "^15.0.0 || ^16.0.0",
"react": "^16.4.0",
"react-redux": "^6.0.0",
"react-router": "^4.3.1",
"react-router": "^4.3.1 || ^5.0.0",
"redux": "^3.6.0 || ^4.0.0"
},
"devDependencies": {
Expand Down Expand Up @@ -66,7 +66,7 @@
"react": "^16.4.0",
"react-dom": "^16.0.0",
"react-redux": "^6.0.0",
"react-router": "^4.3.1",
"react-router": "^4.3.1 || ^5.0.0",
"react-test-renderer": "^16.0.0",
"redux": "^4.0.0",
"redux-devtools": "^3.4.0",
Expand Down

0 comments on commit d327b90

Please sign in to comment.