connected-react-router
Advanced tools
Comparing version 4.5.0 to 5.0.0
31
FAQ.md
# Frequently Asked Questions | ||
---------------------------- | ||
- [How to navigate with Redux action](#how-to-navigate-with-redux-action) | ||
- [How to get the current browser location (URL)](#how-to-get-current-browser-location-url) | ||
- [How to get the current browser location (URL)](#how-to-get-the-current-browser-location-url) | ||
- [How to set Router props e.g. basename, initialEntries, etc.](#how-to-set-router-props-eg-basename-initialentries-etc) | ||
@@ -187,7 +187,7 @@ - [How to hot reload functional components](#how-to-hot-reload-functional-components) | ||
*/ | ||
store.replaceReducer(connectRouter(history)(rootReducer)) | ||
store.replaceReducer(rootReducer(history)) | ||
/* For Webpack 1.x | ||
const nextRootReducer = require('./reducers').default | ||
store.replaceReducer(connectRouter(history)(nextRootReducer)) | ||
store.replaceReducer(nextRootReducer(history)) | ||
*/ | ||
@@ -199,7 +199,11 @@ }) | ||
### How to support Immutable.js | ||
1) Use `combineReducers` from `redux-immutable` to create the root reducer. | ||
1) Create your root reducer as a function that takes `history` and returns reducer. Use `combineReducers` from `redux-immutable` to return the root reducer. | ||
2) Import `connectRouter` from `connected-react-router/immutable` and add router reducer to root reducer | ||
```js | ||
import { combineReducers } from 'redux-immutable' | ||
import { connectRouter } from 'connected-react-router/immutable' | ||
... | ||
const rootReducer = combineReducers({ | ||
const rootReducer = (history) => combineReducers({ | ||
router: connectRouter(history), | ||
... | ||
@@ -210,9 +214,18 @@ }) | ||
2) Import `ConnectedRouter`, `routerMiddleware`, and `connectRouter` from `connected-react-router/immutable` instead of `connected-react-router`. | ||
2) Import `ConnectedRouter` and `routerMiddleware` from `connected-react-router/immutable` instead of `connected-react-router`. | ||
```js | ||
import { ConnectedRouter, routerMiddleware, connectRouter } from 'connected-react-router/immutable' | ||
import { ConnectedRouter, routerMiddleware } from 'connected-react-router/immutable' | ||
``` | ||
3) (Optional) Initialize state with `Immutable.Map()` | ||
3) Create your root reducer with router reducer by passing `history` to `rootReducer` function | ||
```js | ||
const store = createStore( | ||
rootReducer(history), | ||
initialState, | ||
... | ||
) | ||
``` | ||
4) (Optional) Initialize state with `Immutable.Map()` | ||
```js | ||
import Immutable from 'immutable' | ||
@@ -223,3 +236,3 @@ ... | ||
const store = createStore( | ||
connectRouter(history)(rootReducer), | ||
rootReducer(history), | ||
initialState, | ||
@@ -226,0 +239,0 @@ ... |
declare module 'connected-react-router' { | ||
import * as React from 'react' | ||
import { Middleware, Reducer } from 'redux' | ||
import { History, Path, Location, LocationState, LocationDescriptorObject } from 'history' | ||
import * as React from 'react'; | ||
import { Middleware, Reducer } from 'redux'; | ||
import { | ||
History, | ||
Path, | ||
Location, | ||
LocationState, | ||
LocationDescriptorObject | ||
} from 'history'; | ||
interface ConnectedRouterProps { | ||
history: History | ||
history: History; | ||
} | ||
export enum RouterActionType { | ||
POP = 'POP', | ||
PUSH = 'PUSH' | ||
} | ||
export type RouterActionType = 'POP' | 'PUSH' | 'REPLACE'; | ||
export interface LocationChangeAction { | ||
@@ -22,8 +25,20 @@ type: typeof LOCATION_CHANGE; | ||
location: Location | ||
action: RouterActionType.POP | RouterActionType.PUSH | ||
action: RouterActionType | ||
} | ||
export const LOCATION_CHANGE: '@@router/LOCATION_CHANGE' | ||
export const CALL_HISTORY_METHOD: string | ||
export const LOCATION_CHANGE: '@@router/LOCATION_CHANGE'; | ||
export const CALL_HISTORY_METHOD: '@@router/CALL_HISTORY_METHOD'; | ||
export interface LocationChangeAction { | ||
type: typeof LOCATION_CHANGE; | ||
payload: RouterState; | ||
} | ||
export interface CallHistoryMethodAction { | ||
type: typeof CALL_HISTORY_METHOD; | ||
payload: LocationActionPayload; | ||
} | ||
export type RouterAction = LocationChangeAction | CallHistoryMethodAction; | ||
export function push(path: Path, state?: LocationState): RouterAction; | ||
@@ -33,13 +48,13 @@ export function push(location: LocationDescriptorObject): RouterAction; | ||
export function replace(location: LocationDescriptorObject): RouterAction; | ||
export function go(n: number): RouterAction | ||
export function goBack(): RouterAction | ||
export function goForward(): RouterAction | ||
export function go(n: number): RouterAction; | ||
export function goBack(): RouterAction; | ||
export function goForward(): RouterAction; | ||
export const routerActions: { | ||
push: typeof push, | ||
replace: typeof replace, | ||
go: typeof go, | ||
goBack: typeof goBack, | ||
goForward: typeof goForward, | ||
} | ||
push: typeof push; | ||
replace: typeof replace; | ||
go: typeof go; | ||
goBack: typeof goBack; | ||
goForward: typeof goForward; | ||
}; | ||
@@ -51,15 +66,11 @@ export interface LocationActionPayload { | ||
export interface RouterAction { | ||
type: typeof CALL_HISTORY_METHOD; | ||
payload: LocationActionPayload; | ||
} | ||
export class ConnectedRouter extends React.Component< | ||
ConnectedRouterProps, | ||
{} | ||
> {} | ||
export class ConnectedRouter extends React.Component<ConnectedRouterProps, {}> { | ||
} | ||
export function connectRouter(history: History) | ||
: <S>(reducer: Reducer<S>) => Reducer<S> | ||
: <S>(reducer: Reducer<S>) => Reducer<S & { router: RouterState }> | ||
export function routerMiddleware(history: History): Middleware | ||
export function routerMiddleware(history: History): Middleware; | ||
} |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
/** | ||
@@ -101,3 +100,3 @@ * This action type will be dispatched when your history | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -230,2 +229,7 @@ | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -232,0 +236,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +10,2 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -205,3 +205,3 @@ | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -331,2 +331,7 @@ | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -333,0 +338,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +10,2 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -87,3 +87,3 @@ | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -210,2 +210,7 @@ | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -212,0 +217,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +10,2 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _createAll = require('./createAll'); | ||
@@ -92,3 +92,3 @@ | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -203,2 +203,7 @@ | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -205,0 +210,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +10,2 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _createAll = require('./createAll'); | ||
@@ -92,3 +92,3 @@ | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -203,2 +203,7 @@ | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -205,0 +210,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +10,2 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _actions = require('./actions'); | ||
@@ -81,3 +81,3 @@ | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -192,2 +192,7 @@ | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -194,0 +199,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,30 +10,10 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _actions = require('./actions'); | ||
var createConnectRouter = function createConnectRouter(structure) { | ||
var filterNotRouter = structure.filterNotRouter, | ||
fromJS = structure.fromJS, | ||
getIn = structure.getIn, | ||
merge = structure.merge, | ||
setIn = structure.setIn; | ||
/** | ||
* This reducer will update the state with the most recent location history | ||
* has transitioned to. | ||
*/ | ||
var fromJS = structure.fromJS, | ||
merge = structure.merge; | ||
var routerReducer = function routerReducer(state) { | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
type = _ref.type, | ||
payload = _ref.payload; | ||
if (type === _get__('LOCATION_CHANGE')) { | ||
return merge(state, payload); | ||
} | ||
return state; | ||
}; | ||
var connectRouter = function connectRouter(history) { | ||
var createRouterReducer = function createRouterReducer(history) { | ||
var initialRouterState = fromJS({ | ||
@@ -41,20 +23,23 @@ location: history.location, | ||
}); | ||
// Wrap a root reducer and return a new root reducer with router state | ||
return function (rootReducer) { | ||
return function (state, action) { | ||
var routerState = initialRouterState; | ||
// Extract router state | ||
if (state) { | ||
routerState = getIn(state, ['router']) || routerState; | ||
state = filterNotRouter(state); | ||
} | ||
var reducerResults = rootReducer(state, action); | ||
/* | ||
* This reducer will update the state with the most recent location history | ||
* has transitioned to. | ||
*/ | ||
return function () { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialRouterState; | ||
return setIn(reducerResults, ['router'], routerReducer(routerState, action)); | ||
}; | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
type = _ref.type, | ||
payload = _ref.payload; | ||
if (type === _get__('LOCATION_CHANGE')) { | ||
return merge(state, payload); | ||
} | ||
return state; | ||
}; | ||
}; | ||
return connectRouter; | ||
return createRouterReducer; | ||
}; | ||
@@ -104,3 +89,3 @@ | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -215,2 +200,7 @@ | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -217,0 +207,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +10,2 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _createAll = require('./createAll'); | ||
@@ -92,3 +92,3 @@ | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -203,2 +203,7 @@ | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -205,0 +210,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +10,2 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _reactRouter = require('react-router'); | ||
@@ -93,3 +93,3 @@ | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -204,2 +204,7 @@ | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -206,0 +211,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,5 +10,2 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* Code from github.com/erikras/redux-form by Erik Rasmussen */ | ||
var _immutable = require('immutable'); | ||
@@ -20,2 +19,3 @@ | ||
/* Code from github.com/erikras/redux-form by Erik Rasmussen */ | ||
var getIn = function getIn(state, path) { | ||
@@ -67,3 +67,3 @@ return _get__('Iterable').isIterable(state) ? state.getIn(path) : _get__('plainGetIn')(state, path); | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -181,2 +181,7 @@ | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -183,0 +188,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +10,2 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _immutable = require('immutable'); | ||
@@ -17,14 +17,5 @@ | ||
var _setIn = require('./setIn'); | ||
var _setIn2 = _interopRequireDefault(_setIn); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var structure = { | ||
filterNotRouter: function filterNotRouter(state) { | ||
return state.filterNot(function (v, k) { | ||
return k === 'router'; | ||
}); | ||
}, | ||
fromJS: function fromJS(jsValue) { | ||
@@ -39,3 +30,2 @@ return _get__('fromJS')(jsValue, function (key, value) { | ||
}, | ||
setIn: _get__('setIn'), | ||
toJS: function toJS(value) { | ||
@@ -88,3 +78,3 @@ return _get__('Iterable').isIterable(value) ? value.toJS() : value; | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -165,5 +155,2 @@ | ||
case 'setIn': | ||
return _setIn2.default; | ||
case 'structure': | ||
@@ -209,2 +196,7 @@ return structure; | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -211,0 +203,0 @@ if (value === undefined) { |
"use strict"; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
/* Code from github.com/erikras/redux-form by Erik Rasmussen */ | ||
@@ -71,3 +70,3 @@ | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -179,2 +178,7 @@ | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -181,0 +185,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +10,2 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -17,18 +17,5 @@ | ||
var _setIn = require('./setIn'); | ||
var _setIn2 = _interopRequireDefault(_setIn); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
var structure = { | ||
filterNotRouter: function filterNotRouter(state) { | ||
var router = state.router, | ||
rest = _objectWithoutProperties(state, ['router']); // eslint-disable-line no-unused-vars | ||
return rest; | ||
}, | ||
fromJS: function fromJS(value) { | ||
@@ -41,3 +28,2 @@ return value; | ||
}, | ||
setIn: _get__('setIn'), | ||
toJS: function toJS(value) { | ||
@@ -90,3 +76,3 @@ return value; | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -161,5 +147,2 @@ | ||
case 'setIn': | ||
return _setIn2.default; | ||
case 'structure': | ||
@@ -205,2 +188,7 @@ return structure; | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -207,0 +195,0 @@ if (value === undefined) { |
'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,4 +10,2 @@ value: true | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _seamlessImmutable = require('seamless-immutable'); | ||
@@ -19,10 +19,4 @@ | ||
var _setIn = require('../plain/setIn'); | ||
var _setIn2 = _interopRequireDefault(_setIn); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
var _get__2 = _get__('SeamlessImmutable'), | ||
@@ -32,9 +26,2 @@ Immutable = _get__2.static; | ||
var structure = { | ||
filterNotRouter: function filterNotRouter(state) { | ||
var router = state.router, | ||
rest = _objectWithoutProperties(state, ['router']); // eslint-disable-line | ||
return rest; | ||
}, | ||
fromJS: function fromJS(value) { | ||
@@ -47,3 +34,2 @@ return _get__('Immutable').from(value); | ||
}, | ||
setIn: _get__('setIn'), | ||
toJS: function toJS(value) { | ||
@@ -96,3 +82,3 @@ return _get__('Immutable').asMutable(value); | ||
return __$$GLOBAL_REWIRE_REGISTRY__; | ||
return theGlobalVariable.__$$GLOBAL_REWIRE_REGISTRY__; | ||
} | ||
@@ -173,5 +159,2 @@ | ||
case 'setIn': | ||
return _setIn2.default; | ||
case 'structure': | ||
@@ -217,2 +200,7 @@ return structure; | ||
}); | ||
return function () { | ||
Object.keys(variableName).forEach(function (name) { | ||
_reset__(variableName); | ||
}); | ||
}; | ||
} else { | ||
@@ -219,0 +207,0 @@ if (value === undefined) { |
{ | ||
"name": "connected-react-router", | ||
"version": "4.5.0", | ||
"version": "5.0.0", | ||
"description": "A Redux binding for React Router v4", | ||
@@ -28,3 +28,2 @@ "main": "lib/index.js", | ||
"immutable": "^3.8.1", | ||
"redux-seamless-immutable": "^0.4.0", | ||
"seamless-immutable": "^7.1.3" | ||
@@ -40,3 +39,3 @@ }, | ||
"@types/history": "^4.5.0", | ||
"@types/react": "^15.0.23", | ||
"@types/react": "*", | ||
"babel-cli": "^6.18.0", | ||
@@ -71,2 +70,3 @@ "babel-core": "^6.20.0", | ||
"redux-mock-store": "^1.2.1", | ||
"redux-seamless-immutable": "^0.4.0", | ||
"rewire": "^2.5.2", | ||
@@ -82,2 +82,2 @@ "webpack": "^2.2.1" | ||
} | ||
} | ||
} |
@@ -39,3 +39,4 @@ 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) | ||
- Create a `history` object. | ||
- Wrap the root reducer with `connectRouter` and supply the `history` object to get a new root reducer. | ||
- Create root reducer as a function that takes `history` as an argument and returns reducer. | ||
- Add router reducer into root reducer by passing `history` to `connectRouter`. | ||
- Use `routerMiddleware(history)` if you want to dispatch history actions (e.g. to change URL with `push('/path/to/somewhere')`). | ||
@@ -45,2 +46,12 @@ | ||
```js | ||
// reducers.js | ||
import { combineReducers } from "redux"; | ||
import { connectRouter } from 'connected-react-router' | ||
export default (history) => combineReducers({ | ||
router: connectRouter(history), | ||
... // rest of your reducers | ||
}) | ||
// configureStore.js | ||
... | ||
@@ -50,2 +61,3 @@ import { createBrowserHistory } from 'history' | ||
import { connectRouter, routerMiddleware } from 'connected-react-router' | ||
import createRootReducer from "./reducers"; | ||
... | ||
@@ -55,3 +67,3 @@ const history = createBrowserHistory() | ||
const store = createStore( | ||
connectRouter(history)(rootReducer), // new root reducer with router state | ||
createRootReducer(history), // root reducer with router state | ||
initialState, | ||
@@ -103,3 +115,3 @@ compose( | ||
- [How to navigate with Redux action](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-navigate-with-redux-action) | ||
- [How to get the current browser location (URL)](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-get-current-browser-location-url) | ||
- [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) | ||
- [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) | ||
@@ -106,0 +118,0 @@ - [How to hot reload functional components](https://github.com/supasate/connected-react-router/tree/master/FAQ.md#how-to-hot-reload-functional-components) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
132
585336
34
12397
- Removedredux-seamless-immutable@^0.4.0
- Removedreact-router-redux@4.0.8(transitive)
- Removedredux-seamless-immutable@0.4.0(transitive)