react-redux
Advanced tools
Comparing version 5.0.0-beta.1 to 5.0.0-beta.2
@@ -7,3 +7,3 @@ 'use strict'; | ||
exports["default"] = connectAdvanced; | ||
exports.default = connectAdvanced; | ||
@@ -28,3 +28,3 @@ var _hoistNonReactStatics = require('hoist-non-react-statics'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -58,3 +58,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; | ||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -81,7 +81,7 @@ var _ref$getDisplayName = _ref.getDisplayName; | ||
var contextTypes = (_contextTypes = {}, _contextTypes[storeKey] = _storeShape2["default"], _contextTypes[subscriptionKey] = _react.PropTypes.instanceOf(_Subscription2["default"]), _contextTypes); | ||
var childContextTypes = (_childContextTypes = {}, _childContextTypes[subscriptionKey] = _react.PropTypes.instanceOf(_Subscription2["default"]), _childContextTypes); | ||
var contextTypes = (_contextTypes = {}, _contextTypes[storeKey] = _storeShape2.default, _contextTypes[subscriptionKey] = _react.PropTypes.instanceOf(_Subscription2.default), _contextTypes); | ||
var childContextTypes = (_childContextTypes = {}, _childContextTypes[subscriptionKey] = _react.PropTypes.instanceOf(_Subscription2.default), _childContextTypes); | ||
return function wrapWithConnect(WrappedComponent) { | ||
(0, _invariant2["default"])(typeof WrappedComponent == 'function', 'You must pass a component to the function returned by ' + ('connect. Instead received ' + WrappedComponent)); | ||
(0, _invariant2.default)(typeof WrappedComponent == 'function', 'You must pass a component to the function returned by ' + ('connect. Instead received ' + WrappedComponent)); | ||
@@ -118,3 +118,3 @@ var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component'; | ||
(0, _invariant2["default"])(_this.store, 'Could not find "' + storeKey + '" in either the context or ' + ('props of "' + displayName + '". ') + 'Either wrap the root component in a <Provider>, ' + ('or explicitly pass "' + storeKey + '" as a prop to "' + displayName + '".')); | ||
(0, _invariant2.default)(_this.store, 'Could not find "' + storeKey + '" in either the context or ' + ('props of "' + displayName + '". ') + 'Either wrap the root component in a <Provider>, ' + ('or explicitly pass "' + storeKey + '" as a prop to "' + displayName + '".')); | ||
@@ -169,3 +169,3 @@ // make sure `getState` is properly bound in order to avoid breaking | ||
Connect.prototype.getWrappedInstance = function getWrappedInstance() { | ||
(0, _invariant2["default"])(withRef, 'To access the wrapped instance, you need to specify ' + ('{ withRef: true } in the options argument of the ' + methodName + '() call.')); | ||
(0, _invariant2.default)(withRef, 'To access the wrapped instance, you need to specify ' + ('{ withRef: true } in the options argument of the ' + methodName + '() call.')); | ||
return this.wrappedInstance; | ||
@@ -209,3 +209,3 @@ }; | ||
(function () { | ||
var subscription = _this2.subscription = new _Subscription2["default"](_this2.store, _this2.parentSub); | ||
var subscription = _this2.subscription = new _Subscription2.default(_this2.store, _this2.parentSub); | ||
var notifyNestedSubs = subscription.notifyNestedSubs.bind(subscription); | ||
@@ -277,4 +277,4 @@ var dummyState = {}; | ||
return (0, _hoistNonReactStatics2["default"])(Connect, WrappedComponent); | ||
return (0, _hoistNonReactStatics2.default)(Connect, WrappedComponent); | ||
}; | ||
} |
'use strict'; | ||
exports.__esModule = true; | ||
exports["default"] = undefined; | ||
exports.default = undefined; | ||
@@ -16,3 +16,3 @@ var _react = require('react'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -32,3 +32,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
(0, _warning2["default"])('<Provider> does not support changing `store` on the fly. ' + 'It is most likely that you see this error because you updated to ' + 'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' + 'automatically. See https://github.com/reactjs/react-redux/releases/' + 'tag/v2.0.0 for the migration instructions.'); | ||
(0, _warning2.default)('<Provider> does not support changing `store` on the fly. ' + 'It is most likely that you see this error because you updated to ' + 'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' + 'automatically. See https://github.com/reactjs/react-redux/releases/' + 'tag/v2.0.0 for the migration instructions.'); | ||
} | ||
@@ -59,3 +59,3 @@ | ||
exports["default"] = Provider; | ||
exports.default = Provider; | ||
@@ -76,7 +76,8 @@ | ||
Provider.propTypes = { | ||
store: _storeShape2["default"].isRequired, | ||
store: _storeShape2.default.isRequired, | ||
children: _react.PropTypes.element.isRequired | ||
}; | ||
Provider.childContextTypes = { | ||
store: _storeShape2["default"].isRequired | ||
}; | ||
store: _storeShape2.default.isRequired | ||
}; | ||
Provider.displayName = 'Provider'; |
@@ -7,4 +7,3 @@ 'use strict'; | ||
exports.buildConnectOptions = buildConnectOptions; | ||
exports["default"] = connect; | ||
exports.createConnect = createConnect; | ||
@@ -15,2 +14,6 @@ var _connectAdvanced = require('../components/connectAdvanced'); | ||
var _shallowEqual = require('../utils/shallowEqual'); | ||
var _shallowEqual2 = _interopRequireDefault(_shallowEqual); | ||
var _mapDispatchToProps = require('./mapDispatchToProps'); | ||
@@ -32,3 +35,3 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -62,58 +65,68 @@ 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; } | ||
function buildConnectOptions(mapStateToProps, mapDispatchToProps, mergeProps) { | ||
var _ref = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; | ||
function strictEqual(a, b) { | ||
return a === b; | ||
} | ||
// createConnect with default args builds the 'official' connect behavior. Calling it with | ||
// different options opens up some testing and extensibility scenarios | ||
function createConnect() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var _ref$connectHOC = _ref.connectHOC; | ||
var connectHOC = _ref$connectHOC === undefined ? _connectAdvanced2.default : _ref$connectHOC; | ||
var _ref$mapStateToPropsF = _ref.mapStateToPropsFactories; | ||
var mapStateToPropsFactories = _ref$mapStateToPropsF === undefined ? _mapStateToProps2["default"] : _ref$mapStateToPropsF; | ||
var mapStateToPropsFactories = _ref$mapStateToPropsF === undefined ? _mapStateToProps2.default : _ref$mapStateToPropsF; | ||
var _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories; | ||
var mapDispatchToPropsFactories = _ref$mapDispatchToPro === undefined ? _mapDispatchToProps2["default"] : _ref$mapDispatchToPro; | ||
var mapDispatchToPropsFactories = _ref$mapDispatchToPro === undefined ? _mapDispatchToProps2.default : _ref$mapDispatchToPro; | ||
var _ref$mergePropsFactor = _ref.mergePropsFactories; | ||
var mergePropsFactories = _ref$mergePropsFactor === undefined ? _mergeProps2["default"] : _ref$mergePropsFactor; | ||
var mergePropsFactories = _ref$mergePropsFactor === undefined ? _mergeProps2.default : _ref$mergePropsFactor; | ||
var _ref$selectorFactory = _ref.selectorFactory; | ||
var selectorFactory = _ref$selectorFactory === undefined ? _selectorFactory2["default"] : _ref$selectorFactory; | ||
var _ref$pure = _ref.pure; | ||
var pure = _ref$pure === undefined ? true : _ref$pure; | ||
var _ref$__ENABLE_SECRET_ = _ref.__ENABLE_SECRET_EXPERIMENTAL_FEATURES_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
var selectorFactory = _ref$selectorFactory === undefined ? _selectorFactory2.default : _ref$selectorFactory; | ||
var __ENABLE_SECRET_EXPERIMENTAL_FEATURES_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = _ref$__ENABLE_SECRET_ === undefined ? false : _ref$__ENABLE_SECRET_; | ||
return function connect(mapStateToProps, mapDispatchToProps, mergeProps) { | ||
var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
var options = _objectWithoutProperties(_ref, ['mapStateToPropsFactories', 'mapDispatchToPropsFactories', 'mergePropsFactories', 'selectorFactory', 'pure', '__ENABLE_SECRET_EXPERIMENTAL_FEATURES_DO_NOT_USE_OR_YOU_WILL_BE_FIRED']); | ||
var _ref2$pure = _ref2.pure; | ||
var pure = _ref2$pure === undefined ? true : _ref2$pure; | ||
var _ref2$areStatesEqual = _ref2.areStatesEqual; | ||
var areStatesEqual = _ref2$areStatesEqual === undefined ? strictEqual : _ref2$areStatesEqual; | ||
var _ref2$areOwnPropsEqua = _ref2.areOwnPropsEqual; | ||
var areOwnPropsEqual = _ref2$areOwnPropsEqua === undefined ? _shallowEqual2.default : _ref2$areOwnPropsEqua; | ||
var _ref2$areStatePropsEq = _ref2.areStatePropsEqual; | ||
var areStatePropsEqual = _ref2$areStatePropsEq === undefined ? _shallowEqual2.default : _ref2$areStatePropsEq; | ||
var _ref2$areMergedPropsE = _ref2.areMergedPropsEqual; | ||
var areMergedPropsEqual = _ref2$areMergedPropsE === undefined ? _shallowEqual2.default : _ref2$areMergedPropsE; | ||
if (!__ENABLE_SECRET_EXPERIMENTAL_FEATURES_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) { | ||
mapStateToPropsFactories = _mapStateToProps2["default"]; | ||
mapDispatchToPropsFactories = _mapDispatchToProps2["default"]; | ||
mergePropsFactories = _mergeProps2["default"]; | ||
selectorFactory = _selectorFactory2["default"]; | ||
options = { withRef: options.withRef }; | ||
} | ||
var extraOptions = _objectWithoutProperties(_ref2, ['pure', 'areStatesEqual', 'areOwnPropsEqual', 'areStatePropsEqual', 'areMergedPropsEqual']); | ||
var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories); | ||
var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories); | ||
var initMergeProps = match(mergeProps, mergePropsFactories); | ||
var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories); | ||
var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories); | ||
var initMergeProps = match(mergeProps, mergePropsFactories); | ||
return _extends({ | ||
// used in error messages | ||
methodName: 'connect', | ||
return connectHOC(selectorFactory, _extends({ | ||
// used in error messages | ||
methodName: 'connect', | ||
// used to compute Connect's displayName from the wrapped component's displayName. | ||
getDisplayName: function getDisplayName(name) { | ||
return 'Connect(' + name + ')'; | ||
}, | ||
// used to compute Connect's displayName from the wrapped component's displayName. | ||
getDisplayName: function getDisplayName(name) { | ||
return 'Connect(' + name + ')'; | ||
}, | ||
// if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes | ||
shouldHandleStateChanges: Boolean(mapStateToProps), | ||
// if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes | ||
shouldHandleStateChanges: Boolean(mapStateToProps), | ||
// passed through to selectorFactory | ||
selectorFactory: selectorFactory, | ||
initMapStateToProps: initMapStateToProps, | ||
initMapDispatchToProps: initMapDispatchToProps, | ||
initMergeProps: initMergeProps, | ||
pure: pure | ||
// passed through to selectorFactory | ||
initMapStateToProps: initMapStateToProps, | ||
initMapDispatchToProps: initMapDispatchToProps, | ||
initMergeProps: initMergeProps, | ||
pure: pure, | ||
areStatesEqual: areStatesEqual, | ||
areOwnPropsEqual: areOwnPropsEqual, | ||
areStatePropsEqual: areStatePropsEqual, | ||
areMergedPropsEqual: areMergedPropsEqual | ||
}, options); | ||
}, extraOptions)); | ||
}; | ||
} | ||
function connect() { | ||
var options = buildConnectOptions.apply(undefined, arguments); | ||
return (0, _connectAdvanced2["default"])(options.selectorFactory, options); | ||
} | ||
exports.default = createConnect(); |
@@ -28,2 +28,2 @@ 'use strict'; | ||
exports["default"] = [whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject]; | ||
exports.default = [whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject]; |
@@ -19,2 +19,2 @@ 'use strict'; | ||
exports["default"] = [whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing]; | ||
exports.default = [whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing]; |
@@ -12,6 +12,2 @@ 'use strict'; | ||
var _shallowEqual = require('../utils/shallowEqual'); | ||
var _shallowEqual2 = _interopRequireDefault(_shallowEqual); | ||
var _verifyPlainObject = require('../utils/verifyPlainObject'); | ||
@@ -21,5 +17,33 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var _warning = require('../utils/warning'); | ||
var _warning2 = _interopRequireDefault(_warning); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function defaultMergeProps(stateProps, dispatchProps, ownProps) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
var stateKeys = Object.keys(stateProps); | ||
for (var _iterator = stateKeys, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
} | ||
var key = _ref; | ||
if (typeof ownProps[key] !== 'undefined') { | ||
(0, _warning2.default)(false, 'Duplicate key ' + key + ' sent from both parent and state'); | ||
break; | ||
} | ||
} | ||
} | ||
return _extends({}, ownProps, stateProps, dispatchProps); | ||
@@ -29,7 +53,6 @@ } | ||
function wrapMergePropsFunc(mergeProps) { | ||
return function initMergePropsProxy(dispatch, _ref) { | ||
var displayName = _ref.displayName; | ||
var pure = _ref.pure; | ||
var _ref$areMergedPropsEq = _ref.areMergedPropsEqual; | ||
var areMergedPropsEqual = _ref$areMergedPropsEq === undefined ? _shallowEqual2["default"] : _ref$areMergedPropsEq; | ||
return function initMergePropsProxy(dispatch, _ref2) { | ||
var displayName = _ref2.displayName; | ||
var pure = _ref2.pure; | ||
var areMergedPropsEqual = _ref2.areMergedPropsEqual; | ||
@@ -48,3 +71,3 @@ var hasRunOnce = false; | ||
if (process.env.NODE_ENV !== 'production') (0, _verifyPlainObject2["default"])(mergedProps, displayName, 'mergeProps'); | ||
if (process.env.NODE_ENV !== 'production') (0, _verifyPlainObject2.default)(mergedProps, displayName, 'mergeProps'); | ||
} | ||
@@ -67,2 +90,2 @@ | ||
exports["default"] = [whenMergePropsIsFunction, whenMergePropsIsOmitted]; | ||
exports.default = [whenMergePropsIsFunction, whenMergePropsIsOmitted]; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
exports.pureFinalPropsSelectorFactory = pureFinalPropsSelectorFactory; | ||
exports["default"] = finalPropsSelectorFactory; | ||
exports.default = finalPropsSelectorFactory; | ||
@@ -13,8 +13,4 @@ var _verifySubselectors = require('./verifySubselectors'); | ||
var _shallowEqual = require('../utils/shallowEqual'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _shallowEqual2 = _interopRequireDefault(_shallowEqual); | ||
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; } | ||
@@ -28,13 +24,6 @@ | ||
function strictEqual(a, b) { | ||
return a === b; | ||
} | ||
function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, _ref) { | ||
var _ref$areStatesEqual = _ref.areStatesEqual; | ||
var areStatesEqual = _ref$areStatesEqual === undefined ? strictEqual : _ref$areStatesEqual; | ||
var _ref$areOwnPropsEqual = _ref.areOwnPropsEqual; | ||
var areOwnPropsEqual = _ref$areOwnPropsEqual === undefined ? _shallowEqual2["default"] : _ref$areOwnPropsEqual; | ||
var _ref$areStatePropsEqu = _ref.areStatePropsEqual; | ||
var areStatePropsEqual = _ref$areStatePropsEqu === undefined ? _shallowEqual2["default"] : _ref$areStatePropsEqu; | ||
var areStatesEqual = _ref.areStatesEqual; | ||
var areOwnPropsEqual = _ref.areOwnPropsEqual; | ||
var areStatePropsEqual = _ref.areStatePropsEqual; | ||
@@ -122,3 +111,3 @@ var hasRunAtLeastOnce = false; | ||
if (process.env.NODE_ENV !== 'production') { | ||
(0, _verifySubselectors2["default"])(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName); | ||
(0, _verifySubselectors2.default)(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName); | ||
} | ||
@@ -125,0 +114,0 @@ |
'use strict'; | ||
exports.__esModule = true; | ||
exports["default"] = verifySubselectors; | ||
exports.default = verifySubselectors; | ||
@@ -10,3 +10,3 @@ var _warning = require('../utils/warning'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -18,3 +18,3 @@ function verify(selector, methodName, displayName) { | ||
if (!selector.hasOwnProperty('dependsOnOwnProps')) { | ||
(0, _warning2["default"])('The selector for ' + methodName + ' of ' + displayName + ' did not specify a value for dependsOnOwnProps.'); | ||
(0, _warning2.default)('The selector for ' + methodName + ' of ' + displayName + ' did not specify a value for dependsOnOwnProps.'); | ||
} | ||
@@ -21,0 +21,0 @@ } |
@@ -12,3 +12,3 @@ 'use strict'; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -70,3 +70,3 @@ function wrapMapToPropsConstant(getConstant) { | ||
if (process.env.NODE_ENV !== 'production') (0, _verifyPlainObject2["default"])(props, displayName, methodName); | ||
if (process.env.NODE_ENV !== 'production') (0, _verifyPlainObject2.default)(props, displayName, methodName); | ||
@@ -73,0 +73,0 @@ return props; |
'use strict'; | ||
exports.__esModule = true; | ||
exports.connect = exports.Provider = undefined; | ||
exports.connect = exports.connectAdvanced = exports.Provider = undefined; | ||
@@ -10,2 +10,6 @@ var _Provider = require('./components/Provider'); | ||
var _connectAdvanced = require('./components/connectAdvanced'); | ||
var _connectAdvanced2 = _interopRequireDefault(_connectAdvanced); | ||
var _connect = require('./connect/connect'); | ||
@@ -15,5 +19,6 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.Provider = _Provider2["default"]; | ||
exports.connect = _connect2["default"]; | ||
exports.Provider = _Provider2.default; | ||
exports.connectAdvanced = _connectAdvanced2.default; | ||
exports.connect = _connect2.default; |
"use strict"; | ||
exports.__esModule = true; | ||
exports["default"] = shallowEqual; | ||
exports.default = shallowEqual; | ||
var hasOwn = Object.prototype.hasOwnProperty; | ||
@@ -6,0 +6,0 @@ |
@@ -7,3 +7,3 @@ 'use strict'; | ||
exports["default"] = _react.PropTypes.shape({ | ||
exports.default = _react.PropTypes.shape({ | ||
subscribe: _react.PropTypes.func.isRequired, | ||
@@ -10,0 +10,0 @@ dispatch: _react.PropTypes.func.isRequired, |
@@ -90,2 +90,2 @@ "use strict"; | ||
exports["default"] = Subscription; | ||
exports.default = Subscription; |
'use strict'; | ||
exports.__esModule = true; | ||
exports["default"] = verifyPlainObject; | ||
exports.default = verifyPlainObject; | ||
@@ -14,8 +14,8 @@ var _isPlainObject = require('lodash/isPlainObject'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function verifyPlainObject(value, displayName, methodName) { | ||
if (!(0, _isPlainObject2["default"])(value)) { | ||
(0, _warning2["default"])(methodName + '() in ' + displayName + ' must return a plain object. Instead received ' + value + '.'); | ||
if (!(0, _isPlainObject2.default)(value)) { | ||
(0, _warning2.default)(methodName + '() in ' + displayName + ' must return a plain object. Instead received ' + value + '.'); | ||
} | ||
} |
'use strict'; | ||
exports.__esModule = true; | ||
exports["default"] = warning; | ||
exports.default = warning; | ||
/** | ||
@@ -6,0 +6,0 @@ * Prints a warning in the console if it exists. |
'use strict'; | ||
exports.__esModule = true; | ||
exports["default"] = wrapActionCreators; | ||
exports.default = wrapActionCreators; | ||
@@ -6,0 +6,0 @@ var _redux = require('redux'); |
{ | ||
"name": "react-redux", | ||
"version": "5.0.0-beta.1", | ||
"version": "5.0.0-beta.2", | ||
"description": "Official React bindings for Redux", | ||
"main": "./lib/index.js", | ||
"module": "es/index.js", | ||
"jsnext:main": "es/index.js", | ||
"scripts": { | ||
"build:lib": "babel src --out-dir lib", | ||
"build:umd": "cross-env NODE_ENV=development webpack src/index.js dist/react-redux.js", | ||
"build:umd:min": "cross-env NODE_ENV=production webpack src/index.js dist/react-redux.min.js", | ||
"build": "npm run build:lib && npm run build:umd && npm run build:umd:min && node ./prepublish", | ||
"clean": "rimraf lib dist coverage", | ||
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib", | ||
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es", | ||
"build:umd": "cross-env BABEL_ENV=commonjs NODE_ENV=development webpack src/index.js dist/redux.js", | ||
"build:umd:min": "cross-env BABEL_ENV=commonjs NODE_ENV=production webpack src/index.js dist/redux.min.js", | ||
"build": "npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:umd:min", | ||
"clean": "rimraf lib dist es coverage", | ||
"lint": "eslint src test", | ||
"prepublish": "npm run clean && npm run build", | ||
"test": "cross-env NODE_ENV=test mocha --compilers js:babel-register --recursive --require ./test/setup.js", | ||
"test": "cross-env BABEL_ENV=commonjs NODE_ENV=test mocha --compilers js:babel-register --recursive --require ./test/setup.js", | ||
"test:watch": "npm test -- --watch", | ||
@@ -26,3 +29,4 @@ "test:cov": "cross-env NODE_ENV=test nyc npm test", | ||
"lib", | ||
"src" | ||
"src", | ||
"es" | ||
], | ||
@@ -99,2 +103,3 @@ "keywords": [ | ||
"lodash": "^4.2.0", | ||
"lodash-es": "^4.2.0", | ||
"loose-envify": "^1.1.0" | ||
@@ -101,0 +106,0 @@ }, |
@@ -54,1 +54,2 @@ import { Component, PropTypes, Children } from 'react' | ||
} | ||
Provider.displayName = 'Provider' |
import connectAdvanced from '../components/connectAdvanced' | ||
import shallowEqual from '../utils/shallowEqual' | ||
import defaultMapDispatchToPropsFactories from './mapDispatchToProps' | ||
@@ -32,53 +33,56 @@ import defaultMapStateToPropsFactories from './mapStateToProps' | ||
export function buildConnectOptions( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
mergeProps, | ||
{ | ||
mapStateToPropsFactories = defaultMapStateToPropsFactories, | ||
mapDispatchToPropsFactories = defaultMapDispatchToPropsFactories, | ||
mergePropsFactories = defaultMergePropsFactories, | ||
selectorFactory = defaultSelectorFactory, | ||
pure = true, | ||
__ENABLE_SECRET_EXPERIMENTAL_FEATURES_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = false, | ||
...options | ||
} = {} | ||
) { | ||
if (!__ENABLE_SECRET_EXPERIMENTAL_FEATURES_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) { | ||
mapStateToPropsFactories = defaultMapStateToPropsFactories | ||
mapDispatchToPropsFactories = defaultMapDispatchToPropsFactories | ||
mergePropsFactories = defaultMergePropsFactories | ||
selectorFactory = defaultSelectorFactory | ||
options = { withRef: options.withRef } | ||
} | ||
function strictEqual(a, b) { return a === b } | ||
const initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories) | ||
const initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories) | ||
const initMergeProps = match(mergeProps, mergePropsFactories) | ||
// createConnect with default args builds the 'official' connect behavior. Calling it with | ||
// different options opens up some testing and extensibility scenarios | ||
export function createConnect({ | ||
connectHOC = connectAdvanced, | ||
mapStateToPropsFactories = defaultMapStateToPropsFactories, | ||
mapDispatchToPropsFactories = defaultMapDispatchToPropsFactories, | ||
mergePropsFactories = defaultMergePropsFactories, | ||
selectorFactory = defaultSelectorFactory | ||
} = {}) { | ||
return function connect( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
mergeProps, | ||
{ | ||
pure = true, | ||
areStatesEqual = strictEqual, | ||
areOwnPropsEqual = shallowEqual, | ||
areStatePropsEqual = shallowEqual, | ||
areMergedPropsEqual = shallowEqual, | ||
...extraOptions | ||
} = {} | ||
) { | ||
const initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories) | ||
const initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories) | ||
const initMergeProps = match(mergeProps, mergePropsFactories) | ||
return { | ||
// used in error messages | ||
methodName: 'connect', | ||
return connectHOC(selectorFactory, { | ||
// used in error messages | ||
methodName: 'connect', | ||
// used to compute Connect's displayName from the wrapped component's displayName. | ||
getDisplayName: name => `Connect(${name})`, | ||
// used to compute Connect's displayName from the wrapped component's displayName. | ||
getDisplayName: name => `Connect(${name})`, | ||
// if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes | ||
shouldHandleStateChanges: Boolean(mapStateToProps), | ||
// if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes | ||
shouldHandleStateChanges: Boolean(mapStateToProps), | ||
// passed through to selectorFactory | ||
selectorFactory, | ||
initMapStateToProps, | ||
initMapDispatchToProps, | ||
initMergeProps, | ||
pure, | ||
// passed through to selectorFactory | ||
initMapStateToProps, | ||
initMapDispatchToProps, | ||
initMergeProps, | ||
pure, | ||
areStatesEqual, | ||
areOwnPropsEqual, | ||
areStatePropsEqual, | ||
areMergedPropsEqual, | ||
// any addional options args can override defaults of connect or connectAdvanced | ||
...options | ||
// any extra options args can override defaults of connect or connectAdvanced | ||
...extraOptions | ||
}) | ||
} | ||
} | ||
export default function connect(...args) { | ||
const options = buildConnectOptions(...args) | ||
return connectAdvanced(options.selectorFactory, options) | ||
} | ||
export default createConnect() |
@@ -1,6 +0,21 @@ | ||
import shallowEqual from '../utils/shallowEqual' | ||
import verifyPlainObject from '../utils/verifyPlainObject' | ||
import warning from '../utils/warning' | ||
export function defaultMergeProps(stateProps, dispatchProps, ownProps) { | ||
return { ...ownProps, ...stateProps, ...dispatchProps } | ||
if (process.env.NODE_ENV !== 'production') { | ||
const stateKeys = Object.keys(stateProps) | ||
for ( let key of stateKeys ) { | ||
if (typeof ownProps[key] !== 'undefined') { | ||
warning(false, `Duplicate key ${key} sent from both parent and state`) | ||
break | ||
} | ||
} | ||
} | ||
return { | ||
...ownProps, | ||
...stateProps, | ||
...dispatchProps | ||
} | ||
} | ||
@@ -10,3 +25,3 @@ | ||
return function initMergePropsProxy( | ||
dispatch, { displayName, pure, areMergedPropsEqual = shallowEqual } | ||
dispatch, { displayName, pure, areMergedPropsEqual } | ||
) { | ||
@@ -13,0 +28,0 @@ let hasRunOnce = false |
import verifySubselectors from './verifySubselectors' | ||
import shallowEqual from '../utils/shallowEqual' | ||
@@ -19,4 +18,2 @@ export function impureFinalPropsSelectorFactory( | ||
function strictEqual(a, b) { return a === b } | ||
export function pureFinalPropsSelectorFactory( | ||
@@ -27,7 +24,3 @@ mapStateToProps, | ||
dispatch, | ||
{ | ||
areStatesEqual = strictEqual, | ||
areOwnPropsEqual = shallowEqual, | ||
areStatePropsEqual = shallowEqual | ||
} | ||
{ areStatesEqual, areOwnPropsEqual, areStatePropsEqual } | ||
) { | ||
@@ -34,0 +27,0 @@ let hasRunAtLeastOnce = false |
import Provider from './components/Provider' | ||
import connectAdvanced from './components/connectAdvanced' | ||
import connect from './connect/connect' | ||
export { Provider, connect } | ||
export { Provider, connectAdvanced, connect } |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
175780
54
3250
7
18
1
+ Addedlodash-es@^4.2.0