{"name":"connected-react-router","version":"6.3.0","description":"A Redux binding for React Router v4","main":"lib/index.js","module":"esm/index.js","types":"./index.d.ts","sideEffects":false,"author":{"name":"Supasate Choochaisri"},"license":"MIT","scripts":{"build:esm":"BABEL_ENV=esm babel src --out-dir esm","build:commonjs":"BABEL_ENV=commonjs babel src --out-dir lib","build:umd":"NODE_ENV=development webpack src/index.js umd/ConnectedReactRouter.js","build:umd:min":"NODE_ENV=production webpack -p src/index.js umd/ConnectedReactRouter.min.js","build":"npm run build:esm & npm run build:commonjs & npm run build:umd & npm run build:umd:min","lint":"eslint .","test":"jest --config ./.jestrc.json","test:watch":"npm run test -- --watch","posttest":"npm run lint"},"dependencies":{"immutable":"^3.8.1","seamless-immutable":"^7.1.3"},"peerDependencies":{"history":"^4.7.2","react":"^16.4.0","react-redux":"^6.0.0","react-router":"^4.3.1","redux":"^3.6.0 || ^4.0.0"},"devDependencies":{"@babel/cli":"^7.1.5","@babel/core":"^7.1.5","@babel/preset-env":"^7.1.5","@babel/preset-react":"^7.0.0","@types/history":"^4.5.0","@types/react":"*","@types/react-redux":"^7.0.0","@types/react-router":"^4.4.3","babel-core":"7.0.0-bridge.0","babel-eslint":"^10.0.1","babel-jest":"^23.6.0","babel-loader":"^8.0.4","babel-plugin-rewire":"^1.2.0","babel-template":"^6.2.0","babel-types":"^6.2.0","enzyme":"3.1.1","enzyme-adapter-react-16":"^1.0.4","eslint":"^5.9.0","eslint-plugin-import":"^2.14.0","eslint-plugin-react":"^7.11.1","jest":"^23.6.0","prop-types":"^15.5.8","raf":"^3.4.0","react":"^16.4.0","react-dom":"^16.0.0","react-redux":"^6.0.0","react-router":"^4.3.1","react-test-renderer":"^16.0.0","redux":"^4.0.0","redux-devtools":"^3.4.0","redux-immutable":"^3.0.11","redux-mock-store":"^1.2.1","redux-seamless-immutable":"^0.4.0","rewire":"^2.5.2","webpack":"^2.2.1"},"repository":{"type":"git","url":"git+https://github.com/supasate/connected-react-router.git"},"bugs":{"url":"https://github.com/supasate/connected-react-router/issues"},"gitHead":"0f3432c960baced0aca6f8aa9d7f7dceb0716b34","homepage":"https://github.com/supasate/connected-react-router#readme","_id":"connected-react-router@6.3.0","_nodeVersion":"8.12.0","_npmVersion":"6.6.0","dist":{"integrity":"sha512-2U3LSZAxS7V6Hfd0OcpsVGLf93qIzgAn9LQ4taLEFeqHTXcJsykezV0XC+wUJu2KkenvIbfs4fo1/w++j6ogMA==","shasum":"71ef010ca68735fd99374048effdc730da4c918f","tarball":"http://registry-npm.ywwl.com/connected-react-router/download/connected-react-router-6.3.0.tgz","fileCount":41,"unpackedSize":466084,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcYCjmCRA9TVsSAnZWagAAW/YP/RpSCtiV498MPDMK0uag\n57HaKIo/s2p69nJq2ezW+3Tvgf4HVPTaQvFswfnYXZtA8MvKzUS9dkXK13N5\nWkQhbUD3XKkQyMS+a7++Hlxc+T+WiCMGKIEFQhEtuai67AZM/QJ5HRXopZzD\nzGlD9lj/P/VaWkA5gpWblrwDv53j5dzFNVhZOrTE3yEgCU0+yVumyKhR4dh6\nnf2bq7oWjOlImFQeCHb6WoljL7bAwdlL0yPNxlFHG9YZXNEaZEn9djODCUT0\np96luwIJHnuD6jLwnXn4lXz8C/KYeUs+vaSDsA92jywvvxzaUQpg3Vovcm48\nJwikt37Cn2h4b50pchw1UW7IT7zF5hjW3Gp4HkURnAM8TK3yUt2rdwJ2izrp\nwh8n7IrEuj/HUy4YY1UinE+oUcwjZ3jy0dSAe3qlDTsqMtFQsQQJJX3ppmvQ\nvV7c2EQ+0Fbr3t4DNjeTGVuREP1t7X4gv82+VXLEBt05nMehiRqn7ylZrbk7\nqsESry0qYx8Q/kaXcox2aaHOv6aP8G6PwCppToN803K3TEbFJUjh2hMr1nD2\nTWK6WPnDXFKVSWDsOy3ns3DWJa+P1P1kSQ5roIkvkG+CpBdySDOQ8SoESOGR\nMvexTM0Q/5rRbJoOsv7cTjAVlIwT6Z4B0v+c8FDoCTXG3OmnVWGbsjwmYEHS\nQiSr\r\n=N2Bi\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD7zKxY4BSbWOiqOKp28CPJWZcy0IIel+SsUqh+H1UZdgIhALtsuJMMDcfo19+4HGyD2PmxuFGMYLYtr2Hwg02fPAem"}],"size":105557,"noattachment":false,"key":"/connected-react-router/-/connected-react-router-6.3.0.tgz"},"maintainers":[{"name":"supasate","email":"supasate.c@gmail.com"}],"_npmUser":{"name":"supasate","email":"supasate.c@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/connected-react-router_6.3.0_1549805797962_0.009141801815347517"},"_hasShrinkwrap":false,"readme":"> Breaking change in v5.0.0! Please read [How to migrate from v4 to v5/v6](https://github.com/supasate/connected-react-router/blob/master/FAQ.md#how-to-migrate-from-v4-to-v5v6).\n\n> v6.0.0 requires React v16.4.0 and React Redux v6.0 / v7.0.\n\nConnected 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)\n======================\nA Redux binding for React Router v4 and v5\n\nMain features\n-------------\n:sparkles: Synchronize router state with redux store through uni-directional flow (i.e. history -> store -> router -> components).\n\n:gift: Supports [React Router v4 and v5](https://github.com/ReactTraining/react-router).\n\n:sunny: Supports functional component hot reloading while preserving state (with [react-hot-reload](https://github.com/gaearon/react-hot-loader)).\n\n:tada: Dispatching of history methods (`push`, `replace`, `go`, `goBack`, `goForward`) works for both [redux-thunk](https://github.com/gaearon/redux-thunk) and [redux-saga](https://github.com/yelouafi/redux-saga).\n\n:snowman: Nested children can access routing state such as the current location directly with `react-redux`'s `connect`.\n\n:clock9: Supports time traveling in Redux DevTools.\n\n:gem: Supports [Immutable.js](https://facebook.github.io/immutable-js/)\n\n:muscle: Supports TypeScript\n\n\nInstallation\n-----------\nConnected React Router requires **React 16.4 and React Redux 6.0 or later**.\n\n\n    npm install --save connected-react-router\n\nOr\n\n    yarn add connected-react-router\n\nUsage\n-----\n### Step 1\nIn your root reducer file, \n- Create a function that takes `history` as an argument and returns a root reducer.\n- Add `router` reducer into root reducer by passing `history` to `connectRouter`. \n- **Note: The key MUST be `router`**.\n \n```js\n// reducers.js\nimport { combineReducers } from 'redux'\nimport { connectRouter } from 'connected-react-router'\n\nconst createRootReducer = (history) => combineReducers({\n  router: connectRouter(history),\n  ... // rest of your reducers\n})\nexport default createRootReducer\n```\n\n### Step 2\nWhen creating a Redux store,\n- Create a `history` object.\n- Provide the created `history` to the root reducer creator.\n- Use `routerMiddleware(history)` if you want to dispatch history actions (e.g. to change URL with `push('/path/to/somewhere')`).\n\n\n```js\n// configureStore.js\n...\nimport { createBrowserHistory } from 'history'\nimport { applyMiddleware, compose, createStore } from 'redux'\nimport { routerMiddleware } from 'connected-react-router'\nimport createRootReducer from './reducers'\n...\nexport const history = createBrowserHistory()\n\nexport default function configureStore(preloadedState) {\n  const store = createStore(\n    createRootReducer(history), // root reducer with router state\n    preloadedState,\n    compose(\n      applyMiddleware(\n        routerMiddleware(history), // for dispatching history actions\n        // ... other middlewares ...\n      ),\n    ),\n  )\n\n  return store\n}\n```\n\n### Step 3\n\n- 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.\n- Place `ConnectedRouter` as a child of `react-redux`'s `Provider`.\n- **N.B.** If doing server-side rendering, you should still use the `StaticRouter` from `react-router` on the server.\n\n```js\n// index.js\n...\nimport { Provider } from 'react-redux'\nimport { Route, Switch } from 'react-router' // react-router v4/v5\nimport { ConnectedRouter } from 'connected-react-router'\nimport configureStore, { history } from './configureStore'\n...\nconst store = configureStore(/* provide initial state if any */)\n\nReactDOM.render(\n  <Provider store={store}>\n    <ConnectedRouter history={history}> { /* place ConnectedRouter under Provider */ }\n      <> { /* your usual react-router v4/v5 routing */ }\n        <Switch>\n          <Route exact path=\"/\" render={() => (<div>Match</div>)} />\n          <Route render={() => (<div>Miss</div>)} />\n        </Switch>\n      </>\n    </ConnectedRouter>\n  </Provider>,\n  document.getElementById('react-root')\n)\n```\nNote: the `history` object provided to `router` reducer, `routerMiddleware`, and `ConnectedRouter` component must be the same `history` object.\n\nNow, it's ready to work!\n\n\nExamples\n--------\nSee the [examples](https://github.com/supasate/connected-react-router/tree/master/examples) folder\n\n[FAQ](https://github.com/supasate/connected-react-router/tree/master/FAQ.md)\n-----\n- [How to navigate with Redux action](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-navigate-with-redux-action)\n- [How to get the current browser location (URL)](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-get-the-current-browser-location-url)\n- [How to set Router props e.g. basename, initialEntries, etc.](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-set-router-props-eg-basename-initialentries-etc)\n- [How to hot reload functional components](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-hot-reload-functional-components)\n- [How to hot reload reducers](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-hot-reload-reducers)\n- [How to support Immutable.js](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-support-immutablejs)\n- [How to implement server-side rendering](https://medium.com/@cereallarceny/server-side-rendering-in-create-react-app-with-all-the-goodies-without-ejecting-4c889d7db25e) ([sample codebase](https://github.com/cereallarceny/cra-ssr))\n- [How to migrate from v4 to v5](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-migrate-from-v4-to-v5)\n- [How to use connected-react-router with react native](./FAQ.md#how-to-use-connected-react-router-with-react-native)\n- [How to use your own context with react-redux](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-use-your-own-context-with-react-redux)\n\nBuild\n-----\n```bash\nnpm run build\n```\nGenerated files will be in the `lib` folder.\n\nDevelopment\n-----------\nWhen testing the example apps with `npm link` or `yarn link`, you should explicitly provide the same `Context` to both `Provider` and `ConnectedRouter` to make sure that the `ConnectedRouter` doesn't pick up a different `ReactReduxContext` from a different `node_modules` folder.\n\nIn `index.js`.\n```js\n...\nimport { Provider, ReactReduxContext } from 'react-redux'\n...\n      <Provider store={store} context={ReactReduxContext}>\n        <App history={history} context={ReactReduxContext} />\n      </Provider>\n...\n```\n\nIn `App.js`,\n```js\n...\nconst App = ({ history, context }) => {\n  return (\n    <ConnectedRouter history={history} context={context}>\n      { routes }\n    </ConnectedRouter>\n  )\n}\n...\n```\n\nContributors\n------------\nSee [Contributors](https://github.com/supasate/connected-react-router/graphs/contributors) and [Acknowledge](https://github.com/supasate/connected-react-router/blob/master/ACKNOWLEDGE.md).\n\nLicense\n-------\n[MIT License](https://github.com/supasate/connected-react-router/blob/master/LICENSE.md)\n","publish_time":1549805798079,"_cnpm_publish_time":1549805798079,"dist-tags":{"alpha":"7.0.0-alpha.0","latest":"6.9.3","next":"6.2.0-beta.3"}}