react-redux
Advanced tools
Comparing version 1.0.1 to 2.0.0
@@ -10,3 +10,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
root["ReactRedux"] = factory(root["React"], root["Redux"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_10__, __WEBPACK_EXTERNAL_MODULE_11__) { | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_9__, __WEBPACK_EXTERNAL_MODULE_10__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
@@ -64,3 +64,3 @@ /******/ // The module cache | ||
var _react = __webpack_require__(10); | ||
var _react = __webpack_require__(9); | ||
@@ -131,3 +131,3 @@ var _react2 = _interopRequireDefault(_react); | ||
/* WEBPACK VAR INJECTION */(function(process) {'use strict'; | ||
'use strict'; | ||
@@ -370,23 +370,18 @@ exports.__esModule = true; | ||
if ( | ||
// Node-like CommonJS environments (Browserify, Webpack) | ||
typeof process !== 'undefined' && typeof process.env !== 'undefined' && ("development") !== 'production' || | ||
// React Native | ||
typeof __DEV__ !== 'undefined' && __DEV__ //eslint-disable-line no-undef | ||
) { | ||
Connect.prototype.componentWillUpdate = function componentWillUpdate() { | ||
if (this.version === version) { | ||
return; | ||
} | ||
if (true) { | ||
Connect.prototype.componentWillUpdate = function componentWillUpdate() { | ||
if (this.version === version) { | ||
return; | ||
} | ||
// We are hot reloading! | ||
this.version = version; | ||
// We are hot reloading! | ||
this.version = version; | ||
// Update the state and bindings. | ||
this.trySubscribe(); | ||
this.updateStateProps(); | ||
this.updateDispatchProps(); | ||
this.updateState(); | ||
}; | ||
} | ||
// Update the state and bindings. | ||
this.trySubscribe(); | ||
this.updateStateProps(); | ||
this.updateDispatchProps(); | ||
this.updateState(); | ||
}; | ||
} | ||
@@ -399,3 +394,2 @@ return Connect; | ||
module.exports = exports['default']; | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(9))) | ||
@@ -446,18 +440,18 @@ /***/ }, | ||
var didWarn = false; | ||
function warnAboutFunction() { | ||
if (didWarn || requireFunctionChild) { | ||
var didWarnAboutChild = false; | ||
function warnAboutFunctionChild() { | ||
if (didWarnAboutChild || requireFunctionChild) { | ||
return; | ||
} | ||
didWarn = true; | ||
didWarnAboutChild = true; | ||
console.error( // eslint-disable-line no-console | ||
'With React 0.14 and later versions, you no longer need to ' + 'wrap <Provider> child into a function.'); | ||
} | ||
function warnAboutElement() { | ||
if (didWarn || !requireFunctionChild) { | ||
function warnAboutElementChild() { | ||
if (didWarnAboutChild || !requireFunctionChild) { | ||
return; | ||
} | ||
didWarn = true; | ||
didWarnAboutChild = true; | ||
console.error( // eslint-disable-line no-console | ||
@@ -467,2 +461,13 @@ 'With React 0.13, you need to ' + 'wrap <Provider> child into a function. ' + 'This restriction will be removed with React 0.14.'); | ||
var didWarnAboutReceivingStore = false; | ||
function warnAboutReceivingStore() { | ||
if (didWarnAboutReceivingStore) { | ||
return; | ||
} | ||
didWarnAboutReceivingStore = true; | ||
console.error( // eslint-disable-line no-console | ||
'<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/rackt/react-redux/releases/' + 'tag/v2.0.0 for the migration instructions.'); | ||
} | ||
return (function (_Component) { | ||
@@ -472,3 +477,3 @@ _inherits(Provider, _Component); | ||
Provider.prototype.getChildContext = function getChildContext() { | ||
return { store: this.state.store }; | ||
return { store: this.store }; | ||
}; | ||
@@ -495,12 +500,11 @@ | ||
_Component.call(this, props, context); | ||
this.state = { store: props.store }; | ||
this.store = props.store; | ||
} | ||
Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
var store = this.state.store; | ||
var store = this.store; | ||
var nextStore = nextProps.store; | ||
if (store !== nextStore) { | ||
var nextReducer = nextStore.getReducer(); | ||
store.replaceReducer(nextReducer); | ||
warnAboutReceivingStore(); | ||
} | ||
@@ -513,6 +517,6 @@ }; | ||
if (typeof children === 'function') { | ||
warnAboutFunction(); | ||
warnAboutFunctionChild(); | ||
children = children(); | ||
} else { | ||
warnAboutElement(); | ||
warnAboutElementChild(); | ||
} | ||
@@ -607,3 +611,3 @@ | ||
var _redux = __webpack_require__(11); | ||
var _redux = __webpack_require__(10); | ||
@@ -681,94 +685,4 @@ function wrapActionCreators(actionCreators) { | ||
// shim for using process in browser | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_9__; | ||
var process = module.exports = {}; | ||
var queue = []; | ||
var draining = false; | ||
var currentQueue; | ||
var queueIndex = -1; | ||
function cleanUpNextTick() { | ||
draining = false; | ||
if (currentQueue.length) { | ||
queue = currentQueue.concat(queue); | ||
} else { | ||
queueIndex = -1; | ||
} | ||
if (queue.length) { | ||
drainQueue(); | ||
} | ||
} | ||
function drainQueue() { | ||
if (draining) { | ||
return; | ||
} | ||
var timeout = setTimeout(cleanUpNextTick); | ||
draining = true; | ||
var len = queue.length; | ||
while(len) { | ||
currentQueue = queue; | ||
queue = []; | ||
while (++queueIndex < len) { | ||
currentQueue[queueIndex].run(); | ||
} | ||
queueIndex = -1; | ||
len = queue.length; | ||
} | ||
currentQueue = null; | ||
draining = false; | ||
clearTimeout(timeout); | ||
} | ||
process.nextTick = function (fun) { | ||
var args = new Array(arguments.length - 1); | ||
if (arguments.length > 1) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
} | ||
queue.push(new Item(fun, args)); | ||
if (queue.length === 1 && !draining) { | ||
setTimeout(drainQueue, 0); | ||
} | ||
}; | ||
// v8 likes predictible objects | ||
function Item(fun, array) { | ||
this.fun = fun; | ||
this.array = array; | ||
} | ||
Item.prototype.run = function () { | ||
this.fun.apply(null, this.array); | ||
}; | ||
process.title = 'browser'; | ||
process.browser = true; | ||
process.env = {}; | ||
process.argv = []; | ||
process.version = ''; // empty string to avoid regexp issues | ||
process.versions = {}; | ||
function noop() {} | ||
process.on = noop; | ||
process.addListener = noop; | ||
process.once = noop; | ||
process.off = noop; | ||
process.removeListener = noop; | ||
process.removeAllListeners = noop; | ||
process.emit = noop; | ||
process.binding = function (name) { | ||
throw new Error('process.binding is not supported'); | ||
}; | ||
// TODO(shtylman) | ||
process.cwd = function () { return '/' }; | ||
process.chdir = function (dir) { | ||
throw new Error('process.chdir is not supported'); | ||
}; | ||
process.umask = function() { return 0; }; | ||
/***/ }, | ||
@@ -780,8 +694,2 @@ /* 10 */ | ||
/***/ }, | ||
/* 11 */ | ||
/***/ function(module, exports) { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE_11__; | ||
/***/ } | ||
@@ -788,0 +696,0 @@ /******/ ]) |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("redux")):"function"==typeof define&&define.amd?define(["react","redux"],e):"object"==typeof exports?exports.ReactRedux=e(require("react"),require("redux")):t.ReactRedux=e(t.React,t.Redux)}(this,function(t,e){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0;var o=r(10),u=n(o),i=r(2),s=n(i),a=s.default(u.default),c=a.Provider,p=a.connect;e.Provider=c,e.connect=p},function(t,e){"use strict";function r(t){return t.shape({subscribe:t.func.isRequired,dispatch:t.func.isRequired,getState:t.func.isRequired})}e.__esModule=!0,e.default=r,t.exports=e.default},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t){var e=i.default(t),r=a.default(t);return{Provider:e,connect:r}}e.__esModule=!0,e.default=o;var u=r(4),i=n(u),s=r(3),a=n(s);t.exports=e.default},function(t,e,r){(function(n){"use strict";function o(t){return t&&t.__esModule?t:{"default":t}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t){return t.displayName||t.name||"Component"}function a(t){var e=t.Component,r=t.PropTypes,o=l.default(r);return function(r,a,f){function l(t,e){var r=t.getState(),n=R?g(r,e):g(r);return _.default(v.default(n),"`mapStateToProps` must return an object. Instead received %s.",n),n}function d(t,e){var r=t.dispatch,n=T?O(r,e):O(r);return _.default(v.default(n),"`mapDispatchToProps` must return an object. Instead received %s.",n),n}function y(t,e,r){var n=S(t,e,r);return _.default(v.default(n),"`mergeProps` must return an object. Instead received %s.",n),n}var b=Boolean(r),g=r||x,O=v.default(a)?m.default(a):a||P,S=f||w,R=g.length>1,T=O.length>1,C=j++;return function(r){var a=function(e){function n(t,r){u(this,n),e.call(this,t,r),this.version=C,this.store=t.store||r.store,_.default(this.store,'Could not find "store" in either the context or '+('props of "'+this.constructor.displayName+'". ')+"Either wrap the root component in a <Provider>, "+('or explicitly pass "store" as a prop to "'+this.constructor.displayName+'".')),this.stateProps=l(this.store,t),this.dispatchProps=d(this.store,t),this.state={props:this.computeNextState()}}return i(n,e),n.prototype.shouldComponentUpdate=function(t,e){return!h.default(this.state.props,e.props)},c(n,null,[{key:"displayName",value:"Connect("+s(r)+")",enumerable:!0},{key:"WrappedComponent",value:r,enumerable:!0},{key:"contextTypes",value:{store:o},enumerable:!0},{key:"propTypes",value:{store:o},enumerable:!0}]),n.prototype.computeNextState=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0];return y(this.stateProps,this.dispatchProps,t)},n.prototype.updateStateProps=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=l(this.store,t);return h.default(e,this.stateProps)?!1:(this.stateProps=e,!0)},n.prototype.updateDispatchProps=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=d(this.store,t);return h.default(e,this.dispatchProps)?!1:(this.dispatchProps=e,!0)},n.prototype.updateState=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=this.computeNextState(t);h.default(e,this.state.props)||this.setState({props:e})},n.prototype.isSubscribed=function(){return"function"==typeof this.unsubscribe},n.prototype.trySubscribe=function(){b&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},n.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},n.prototype.componentDidMount=function(){this.trySubscribe()},n.prototype.componentWillReceiveProps=function(t){h.default(t,this.props)||(R&&this.updateStateProps(t),T&&this.updateDispatchProps(t),this.updateState(t))},n.prototype.componentWillUnmount=function(){this.tryUnsubscribe()},n.prototype.handleChange=function(){this.updateStateProps()&&this.updateState()},n.prototype.getWrappedInstance=function(){return this.refs.wrappedInstance},n.prototype.render=function(){return t.createElement(r,p({ref:"wrappedInstance"},this.state.props))},n}(e);return"undefined"!=typeof n&&"undefined"!=typeof n.env,"undefined"!=typeof __DEV__&&__DEV__&&(a.prototype.componentWillUpdate=function(){this.version!==C&&(this.version=C,this.trySubscribe(),this.updateStateProps(),this.updateDispatchProps(),this.updateState())}),a}}}e.__esModule=!0;var c=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),p=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.default=a;var f=r(1),l=o(f),d=r(6),h=o(d),y=r(5),v=o(y),b=r(7),m=o(b),g=r(8),_=o(g),x=function(){return{}},P=function(t){return{dispatch:t}},w=function(t,e,r){return p({},r,t,e)},j=0;t.exports=e.default}).call(e,r(9))},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function i(t){var e=t.version;if("string"!=typeof e)return!0;var r=e.split("."),n=parseInt(r[0],10),o=parseInt(r[1],10);return 0===n&&13===o}function s(t){function e(){d||l||(d=!0,console.error("With React 0.14 and later versions, you no longer need to wrap <Provider> child into a function."))}function r(){!d&&l&&(d=!0,console.error("With React 0.13, you need to wrap <Provider> child into a function. This restriction will be removed with React 0.14."))}var n=t.Component,s=t.PropTypes,c=t.Children,f=p.default(s),l=i(t),d=!1;return function(t){function n(e,r){o(this,n),t.call(this,e,r),this.state={store:e.store}}return u(n,t),n.prototype.getChildContext=function(){return{store:this.state.store}},a(n,null,[{key:"childContextTypes",value:{store:f.isRequired},enumerable:!0},{key:"propTypes",value:{store:f.isRequired,children:(l?s.func:s.element).isRequired},enumerable:!0}]),n.prototype.componentWillReceiveProps=function(t){var e=this.state.store,r=t.store;if(e!==r){var n=r.getReducer();e.replaceReducer(n)}},n.prototype.render=function(){var t=this.props.children;return"function"==typeof t?(e(),t=t()):r(),c.only(t)},n}(n)}e.__esModule=!0;var a=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();e.default=s;var c=r(1),p=n(c);t.exports=e.default},function(t,e){"use strict";function r(t){if(!t||"object"!=typeof t)return!1;var e="function"==typeof t.constructor?Object.getPrototypeOf(t):Object.prototype;if(null===e)return!0;var r=e.constructor;return"function"==typeof r&&r instanceof r&&n(r)===n(Object)}e.__esModule=!0,e.default=r;var n=function(t){return Function.prototype.toString.call(t)};t.exports=e.default},function(t,e){"use strict";function r(t,e){if(t===e)return!0;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<r.length;u++)if(!o.call(e,r[u])||t[r[u]]!==e[r[u]])return!1;return!0}e.__esModule=!0,e.default=r,t.exports=e.default},function(t,e,r){"use strict";function n(t){return function(e){return o.bindActionCreators(t,e)}}e.__esModule=!0,e.default=n;var o=r(11);t.exports=e.default},function(t,e,r){"use strict";var n=function(t,e,r,n,o,u,i,s){if(!t){var a;if(void 0===e)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[r,n,o,u,i,s],p=0;a=new Error("Invariant Violation: "+e.replace(/%s/g,function(){return c[p++]}))}throw a.framesToPop=1,a}};t.exports=n},function(t,e){function r(){c=!1,i.length?a=i.concat(a):p=-1,a.length&&n()}function n(){if(!c){var t=setTimeout(r);c=!0;for(var e=a.length;e;){for(i=a,a=[];++p<e;)i[p].run();p=-1,e=a.length}i=null,c=!1,clearTimeout(t)}}function o(t,e){this.fun=t,this.array=e}function u(){}var i,s=t.exports={},a=[],c=!1,p=-1;s.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];a.push(new o(t,e)),1!==a.length||c||setTimeout(n,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=u,s.addListener=u,s.once=u,s.off=u,s.removeListener=u,s.removeAllListeners=u,s.emit=u,s.binding=function(t){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(t){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},function(e,r){e.exports=t},function(t,r){t.exports=e}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("redux")):"function"==typeof define&&define.amd?define(["react","redux"],e):"object"==typeof exports?exports.ReactRedux=e(require("react"),require("redux")):t.ReactRedux=e(t.React,t.Redux)}(this,function(t,e){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0;var o=r(9),u=n(o),i=r(2),s=n(i),a=s.default(u.default),c=a.Provider,p=a.connect;e.Provider=c,e.connect=p},function(t,e){"use strict";function r(t){return t.shape({subscribe:t.func.isRequired,dispatch:t.func.isRequired,getState:t.func.isRequired})}e.__esModule=!0,e.default=r,t.exports=e.default},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t){var e=i.default(t),r=a.default(t);return{Provider:e,connect:r}}e.__esModule=!0,e.default=o;var u=r(4),i=n(u),s=r(3),a=n(s);t.exports=e.default},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function i(t){return t.displayName||t.name||"Component"}function s(t){var e=t.Component,r=t.PropTypes,n=f.default(r);return function(r,s,p){function f(t,e){var r=t.getState(),n=R?m(r,e):m(r);return g.default(y.default(n),"`mapStateToProps` must return an object. Instead received %s.",n),n}function l(t,e){var r=t.dispatch,n=S?j(r,e):j(r);return g.default(y.default(n),"`mapDispatchToProps` must return an object. Instead received %s.",n),n}function h(t,e,r){var n=O(t,e,r);return g.default(y.default(n),"`mergeProps` must return an object. Instead received %s.",n),n}var b=Boolean(r),m=r||x,j=y.default(s)?v.default(s):s||P,O=p||_,R=m.length>1,S=j.length>1,C=w++;return function(r){var s=function(e){function s(t,r){o(this,s),e.call(this,t,r),this.version=C,this.store=t.store||r.store,g.default(this.store,'Could not find "store" in either the context or '+('props of "'+this.constructor.displayName+'". ')+"Either wrap the root component in a <Provider>, "+('or explicitly pass "store" as a prop to "'+this.constructor.displayName+'".')),this.stateProps=f(this.store,t),this.dispatchProps=l(this.store,t),this.state={props:this.computeNextState()}}return u(s,e),s.prototype.shouldComponentUpdate=function(t,e){return!d.default(this.state.props,e.props)},a(s,null,[{key:"displayName",value:"Connect("+i(r)+")",enumerable:!0},{key:"WrappedComponent",value:r,enumerable:!0},{key:"contextTypes",value:{store:n},enumerable:!0},{key:"propTypes",value:{store:n},enumerable:!0}]),s.prototype.computeNextState=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0];return h(this.stateProps,this.dispatchProps,t)},s.prototype.updateStateProps=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=f(this.store,t);return d.default(e,this.stateProps)?!1:(this.stateProps=e,!0)},s.prototype.updateDispatchProps=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=l(this.store,t);return d.default(e,this.dispatchProps)?!1:(this.dispatchProps=e,!0)},s.prototype.updateState=function(){var t=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],e=this.computeNextState(t);d.default(e,this.state.props)||this.setState({props:e})},s.prototype.isSubscribed=function(){return"function"==typeof this.unsubscribe},s.prototype.trySubscribe=function(){b&&!this.unsubscribe&&(this.unsubscribe=this.store.subscribe(this.handleChange.bind(this)),this.handleChange())},s.prototype.tryUnsubscribe=function(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)},s.prototype.componentDidMount=function(){this.trySubscribe()},s.prototype.componentWillReceiveProps=function(t){d.default(t,this.props)||(R&&this.updateStateProps(t),S&&this.updateDispatchProps(t),this.updateState(t))},s.prototype.componentWillUnmount=function(){this.tryUnsubscribe()},s.prototype.handleChange=function(){this.updateStateProps()&&this.updateState()},s.prototype.getWrappedInstance=function(){return this.refs.wrappedInstance},s.prototype.render=function(){return t.createElement(r,c({ref:"wrappedInstance"},this.state.props))},s}(e);return s}}}e.__esModule=!0;var a=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.default=s;var p=r(1),f=n(p),l=r(6),d=n(l),h=r(5),y=n(h),b=r(7),v=n(b),m=r(8),g=n(m),x=function(){return{}},P=function(t){return{dispatch:t}},_=function(t,e,r){return c({},r,t,e)},w=0;t.exports=e.default},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function i(t){var e=t.version;if("string"!=typeof e)return!0;var r=e.split("."),n=parseInt(r[0],10),o=parseInt(r[1],10);return 0===n&&13===o}function s(t){function e(){h||d||(h=!0,console.error("With React 0.14 and later versions, you no longer need to wrap <Provider> child into a function."))}function r(){!h&&d&&(h=!0,console.error("With React 0.13, you need to wrap <Provider> child into a function. This restriction will be removed with React 0.14."))}function n(){y||(y=!0,console.error("<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/rackt/react-redux/releases/tag/v2.0.0 for the migration instructions."))}var s=t.Component,c=t.PropTypes,f=t.Children,l=p.default(c),d=i(t),h=!1,y=!1;return function(t){function i(e,r){o(this,i),t.call(this,e,r),this.store=e.store}return u(i,t),i.prototype.getChildContext=function(){return{store:this.store}},a(i,null,[{key:"childContextTypes",value:{store:l.isRequired},enumerable:!0},{key:"propTypes",value:{store:l.isRequired,children:(d?c.func:c.element).isRequired},enumerable:!0}]),i.prototype.componentWillReceiveProps=function(t){var e=this.store,r=t.store;e!==r&&n()},i.prototype.render=function(){var t=this.props.children;return"function"==typeof t?(e(),t=t()):r(),f.only(t)},i}(s)}e.__esModule=!0;var a=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}();e.default=s;var c=r(1),p=n(c);t.exports=e.default},function(t,e){"use strict";function r(t){if(!t||"object"!=typeof t)return!1;var e="function"==typeof t.constructor?Object.getPrototypeOf(t):Object.prototype;if(null===e)return!0;var r=e.constructor;return"function"==typeof r&&r instanceof r&&n(r)===n(Object)}e.__esModule=!0,e.default=r;var n=function(t){return Function.prototype.toString.call(t)};t.exports=e.default},function(t,e){"use strict";function r(t,e){if(t===e)return!0;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<r.length;u++)if(!o.call(e,r[u])||t[r[u]]!==e[r[u]])return!1;return!0}e.__esModule=!0,e.default=r,t.exports=e.default},function(t,e,r){"use strict";function n(t){return function(e){return o.bindActionCreators(t,e)}}e.__esModule=!0,e.default=n;var o=r(10);t.exports=e.default},function(t,e,r){"use strict";var n=function(t,e,r,n,o,u,i,s){if(!t){var a;if(void 0===e)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[r,n,o,u,i,s],p=0;a=new Error("Invariant Violation: "+e.replace(/%s/g,function(){return c[p++]}))}throw a.framesToPop=1,a}};t.exports=n},function(e,r){e.exports=t},function(t,r){t.exports=e}])}); |
@@ -239,23 +239,18 @@ 'use strict'; | ||
if ( | ||
// Node-like CommonJS environments (Browserify, Webpack) | ||
typeof process !== 'undefined' && typeof process.env !== 'undefined' && process.env.NODE_ENV !== 'production' || | ||
// React Native | ||
typeof __DEV__ !== 'undefined' && __DEV__ //eslint-disable-line no-undef | ||
) { | ||
Connect.prototype.componentWillUpdate = function componentWillUpdate() { | ||
if (this.version === version) { | ||
return; | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
Connect.prototype.componentWillUpdate = function componentWillUpdate() { | ||
if (this.version === version) { | ||
return; | ||
} | ||
// We are hot reloading! | ||
this.version = version; | ||
// We are hot reloading! | ||
this.version = version; | ||
// Update the state and bindings. | ||
this.trySubscribe(); | ||
this.updateStateProps(); | ||
this.updateDispatchProps(); | ||
this.updateState(); | ||
}; | ||
} | ||
// Update the state and bindings. | ||
this.trySubscribe(); | ||
this.updateStateProps(); | ||
this.updateDispatchProps(); | ||
this.updateState(); | ||
}; | ||
} | ||
@@ -262,0 +257,0 @@ return Connect; |
@@ -41,18 +41,18 @@ 'use strict'; | ||
var didWarn = false; | ||
function warnAboutFunction() { | ||
if (didWarn || requireFunctionChild) { | ||
var didWarnAboutChild = false; | ||
function warnAboutFunctionChild() { | ||
if (didWarnAboutChild || requireFunctionChild) { | ||
return; | ||
} | ||
didWarn = true; | ||
didWarnAboutChild = true; | ||
console.error( // eslint-disable-line no-console | ||
'With React 0.14 and later versions, you no longer need to ' + 'wrap <Provider> child into a function.'); | ||
} | ||
function warnAboutElement() { | ||
if (didWarn || !requireFunctionChild) { | ||
function warnAboutElementChild() { | ||
if (didWarnAboutChild || !requireFunctionChild) { | ||
return; | ||
} | ||
didWarn = true; | ||
didWarnAboutChild = true; | ||
console.error( // eslint-disable-line no-console | ||
@@ -62,2 +62,13 @@ 'With React 0.13, you need to ' + 'wrap <Provider> child into a function. ' + 'This restriction will be removed with React 0.14.'); | ||
var didWarnAboutReceivingStore = false; | ||
function warnAboutReceivingStore() { | ||
if (didWarnAboutReceivingStore) { | ||
return; | ||
} | ||
didWarnAboutReceivingStore = true; | ||
console.error( // eslint-disable-line no-console | ||
'<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/rackt/react-redux/releases/' + 'tag/v2.0.0 for the migration instructions.'); | ||
} | ||
return (function (_Component) { | ||
@@ -67,3 +78,3 @@ _inherits(Provider, _Component); | ||
Provider.prototype.getChildContext = function getChildContext() { | ||
return { store: this.state.store }; | ||
return { store: this.store }; | ||
}; | ||
@@ -90,12 +101,11 @@ | ||
_Component.call(this, props, context); | ||
this.state = { store: props.store }; | ||
this.store = props.store; | ||
} | ||
Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
var store = this.state.store; | ||
var store = this.store; | ||
var nextStore = nextProps.store; | ||
if (store !== nextStore) { | ||
var nextReducer = nextStore.getReducer(); | ||
store.replaceReducer(nextReducer); | ||
warnAboutReceivingStore(); | ||
} | ||
@@ -108,6 +118,6 @@ }; | ||
if (typeof children === 'function') { | ||
warnAboutFunction(); | ||
warnAboutFunctionChild(); | ||
children = children(); | ||
} else { | ||
warnAboutElement(); | ||
warnAboutElementChild(); | ||
} | ||
@@ -114,0 +124,0 @@ |
{ | ||
"name": "react-redux", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Official React bindings for Redux", | ||
@@ -55,3 +55,3 @@ "main": "./lib/index.js", | ||
"react-addons-test-utils": "^0.14.0-beta3", | ||
"redux": "^1.0.1", | ||
"redux": "^2.0.0", | ||
"rimraf": "^2.3.4", | ||
@@ -64,4 +64,4 @@ "webpack": "^1.11.0" | ||
"peerDependencies": { | ||
"redux": "^1.0.0 || 1.0.0-rc" | ||
"redux": "^2.0.0" | ||
} | ||
} |
@@ -32,3 +32,3 @@ React Redux | ||
Be careful! **“React” goes first.** | ||
There is a project called `redux-react` but it is [completely unrelated](https://github.com/cgarvis/redux-react/issues/1). | ||
There is a project called `redux-react`, but it is [completely unrelated](https://github.com/cgarvis/redux-react/issues/1). | ||
@@ -78,3 +78,3 @@ React Redux requires **React 0.13 or later.** | ||
### “Dumb” component is unaware of Redux | ||
### “Dumb” components are unaware of Redux | ||
@@ -97,7 +97,7 @@ Let’s say we have a `<Counter />` “dumb” component with a number `value` prop, and an `onIncrement` function prop that it will call when user presses an “Increment” button: | ||
### “Smart” component is `connect()`-ed to Redux | ||
### “Smart” components are `connect()`-ed to Redux | ||
Here’s how we hook it up to the Redux Store. | ||
We will use `connect()` function provided by `react-redux` to turn a “dumb” `Counter` into a smart component. The `connect()` function lets you specify *which exact* state from the Redux store your component wants to track. This lets you subscribe on any level of granularity. | ||
We will use the `connect()` function provided by `react-redux` to turn a “dumb” `Counter` into a smart component. The `connect()` function lets you specify *which exact* state from the Redux store your component wants to track. This lets you subscribe on any level of granularity. | ||
@@ -141,3 +141,3 @@ ##### `containers/CounterContainer.js` | ||
Whether to put `connect()` call in the same file as the “dumb” component, or separately, is up to you. | ||
Whether to put the `connect()` call in the same file as the “dumb” component, or separately, is up to you. | ||
Ask yourself whether you'd want to reuse this component but bind it to different data, or not. | ||
@@ -147,8 +147,8 @@ | ||
You can have many `connect()`-ed components in your app at any depth, and you can even nest them. It is however preferable that you try to only `connect()` top-level components such as route handlers, so the data flow in your application stays predictable. | ||
You can have many `connect()`-ed components in your app at any depth, and you can even nest them. It is, however, preferable that you try to only `connect()` top-level components such as route handlers, so the data flow in your application stays predictable. | ||
### Support for Decorators | ||
You might have noticed that we used parens twice. This is called partial applications, and it lets people | ||
use ES7 decorator proposal syntax: | ||
You might have noticed that we used parens twice when calling `connect()`. This is called partial application, and it lets people | ||
use ES7’s proposed decorator syntax: | ||
@@ -161,13 +161,13 @@ ```js | ||
Don’t forget decorators are experimental! And they desugar to function calls anyway as example above demonstrates. | ||
Don’t forget decorators are experimental! They desugar to function calls anyway as the example above demonstrates. | ||
### Additional Flexibility | ||
This is the most basic usage, but `connect()` supports many other different patterns: just passing the vanilla `dispatch()` function down, binding multiple action creators, putting them as `actions` prop, selecting parts of state and binding action creators depending on `props`, and so on. Check out `connect()` docs below to learn more. | ||
This is the most basic usage, but `connect()` supports many other patterns: just passing the vanilla `dispatch()` function down, binding multiple action creators, passing them in an `actions` prop, selecting parts of state and binding action creators depending on `props`, and so on. Check out the `connect()` docs below to learn more. | ||
### Injecting Redux Store | ||
Finally, how do we actually hook it up to a Redux store? We need to create the store somewhere at the root of our component hierarchy. For client apps, the root component is a good place. For server rendering, you can do this in the request handler. | ||
Finally, how do we actually hook it up to the Redux store? We need to create the store somewhere at the root of our component hierarchy. For client apps, the root component is a good place. For server rendering, you can do this in the request handler. | ||
The trick is to wrap the whole view hierarchy into `<Provider>{() => ... }</Provider>` where `Provider` is imported from `react-redux`. One gotcha is that **the child of `Provider` must be a function**. This is to work around an issue about how context (undocumented feature we have to rely on to pass Redux data to components below) works in React 0.13. In React 0.14, you will be able to put your view hierarchy in `<Provider>` without wrapping it into a function. | ||
The trick is to wrap the whole view hierarchy into a `<Provider>{() => ... }</Provider>` where `Provider` is imported from `react-redux`. One gotcha is that **the child of `Provider` must be a function**. This is to work around an issue about how context (undocumented feature we have to rely on to pass Redux data to components below) works in React 0.13. In React 0.14, you will be able to put your view hierarchy in `<Provider>` without wrapping it into a function. | ||
@@ -197,3 +197,3 @@ ```js | ||
Makes Redux store available to the `connect()` calls in the component hierarchy below. Normally, you can’t use `connect()` without wrapping the root component in `<Provider>`. (If you *really* need to, you can manually pass `store` as a prop to every `connect()`ed component, but we only recommend to do this for stubbing `store` in unit tests, or in non-fully-React codebases. Normally, you should just use `<Provider>`.) | ||
Makes the Redux store available to the `connect()` calls in the component hierarchy below. Normally, you can’t use `connect()` without wrapping the root component in `<Provider>`. (If you *really* need to, you can manually pass `store` as a prop to every `connect()`ed component, but we only recommend to do this for stubbing `store` in unit tests, or in non-fully-React codebases. Normally, you should just use `<Provider>`.) | ||
@@ -248,5 +248,5 @@ #### Props | ||
* [`mapStateToProps(state, [ownProps]): stateProps`] \(*Function*): If specified, the component will subscribe to Redux store updates. Any time it updates, `mapStateToProps` will be called. Its result must be a plain object, and it will be merged into the component’s props. If you omit it, the component will not be subscribed to the Redux store. If `ownProps` is specified as a second argument then `mapStateToProps` will be re-invoked whenever the component receives new props. | ||
* [`mapStateToProps(state, [ownProps]): stateProps`] \(*Function*): If specified, the component will subscribe to Redux store updates. Any time it updates, `mapStateToProps` will be called. Its result must be a plain object, and it will be merged into the component’s props. If you omit it, the component will not be subscribed to the Redux store. If `ownProps` is specified as a second argument, then `mapStateToProps` will be re-invoked whenever the component receives new props. | ||
* [`mapDispatchToProps(dispatch, [ownProps]): dispatchProps`] \(*Object* or *Function*): If an object is passed, each function inside it will be assumed to be a Redux action creator. An object with the same function names, but bound to a Redux store, will be merged into the component’s props. If a function is passed, it will be given `dispatch`. It’s up to you to return an object that somehow uses `dispatch` to bind action creators in your own way. (Tip: you may use [`bindActionCreators()`](http://gaearon.github.io/redux/docs/api/bindActionCreators.html) helper from Redux.) If you omit it, the default implementation just injects `dispatch` into your component’s props. If `ownProps` is specified as a second argument then `mapDispatchToProps` will be re-invoked whenever the component receives new props. | ||
* [`mapDispatchToProps(dispatch, [ownProps]): dispatchProps`] \(*Object* or *Function*): If an object is passed, each function inside it will be assumed to be a Redux action creator. An object with the same function names, but bound to a Redux store, will be merged into the component’s props. If a function is passed, it will be given `dispatch`. It’s up to you to return an object that somehow uses `dispatch` to bind action creators in your own way. (Tip: you may use the [`bindActionCreators()`](http://gaearon.github.io/redux/docs/api/bindActionCreators.html) helper from Redux.) If you omit it, the default implementation just injects `dispatch` into your component’s props. If `ownProps` is specified as a second argument, then `mapDispatchToProps` will be re-invoked whenever the component receives new props. | ||
@@ -261,7 +261,7 @@ * [`mergeProps(stateProps, dispatchProps, ownProps): props`] \(*Function*): If specified, it is passed the result of `mapStateToProps()`, `mapDispatchToProps()`, and the parent `props`. The plain object you return from it will be passed as props to the wrapped component. You may specify this function to select a slice of the state based on props, or to bind action creators to a particular variable from props. If you omit it, `Object.assign({}, ownProps, stateProps, dispatchProps)` is used by default. | ||
* It needs to be invoked two times. First time with its arguments described above, and second time, with the component: `connect(mapStateToProps, mapDispatchToProps, mergeProps)(MyComponent)`. | ||
* It needs to be invoked two times. The first time with its arguments described above, and a second time, with the component: `connect(mapStateToProps, mapDispatchToProps, mergeProps)(MyComponent)`. | ||
* The `mapStateToProps` function takes a single argument of the entire Redux store’s state and returns an object to be passed as props. It is often called a **selector**. Use [reselect](https://github.com/faassen/reselect) to efficiently compose selectors and [compute derived data](http://gaearon.github.io/redux/docs/recipes/ComputingDerivedData.html). | ||
* **To use `connect()`, the root component of your app must be wrapped into `<Provider>{() => ... }</Provider>` before being rendered.** You may also pass `store` as a prop to the `connect()`ed component, but it's not recommended because it's just too much trouble. Only do this for in non-fully-React codebases or to stub store in a unit test. | ||
* **To use `connect()`, the root component of your app must be wrapped into `<Provider>{() => ... }</Provider>` before being rendered.** You may also pass `store` as a prop to the `connect()`ed component, but it's not recommended, because it's just too much trouble. Only do this for non-fully-React codebases or to stub the store in a unit test. | ||
@@ -278,3 +278,3 @@ #### Examples | ||
>Don’t do this! It kills any performance optimisations because `TodoApp` will rerender after any action. | ||
>Don’t do this! It kills any performance optimisations because `TodoApp` will rerender after every action. | ||
>It’s better to have more granular `connect()` on several components in your view hierarchy. | ||
@@ -442,3 +442,3 @@ | ||
* Reducers should never mutate state, they must return new objects, or React Redux won’t see the updates. | ||
* Make sure you either bind action creators with `mapDispatchToState` argument to `connect()` or with `bindActionCreators()` method, or that you manually call `dispatch()`. Just calling your `MyActionCreators.addTodo()` function won’t work because it just *returns* an action, but not *dispatches* it. | ||
* Make sure you either bind action creators with the `mapDispatchToProps` argument to `connect()` or with the `bindActionCreators()` method, or that you manually call `dispatch()`. Just calling your `MyActionCreators.addTodo()` function won’t work because it just *returns* an action, but does not *dispatch* it. | ||
@@ -478,8 +478,14 @@ ### My views aren’t updating on route change with React Router 0.13 | ||
1. [Make sure you don’t have duplicate React](https://medium.com/@dan_abramov/two-weird-tricks-that-fix-react-7cf9bbdef375) on the page. | ||
1. [Make sure you don’t have a duplicate instance of React](https://medium.com/@dan_abramov/two-weird-tricks-that-fix-react-7cf9bbdef375) on the page. | ||
2. Make sure you didn’t forget to wrap your root component in [`<Provider>`](#provider-store). | ||
3. If you use React Router, something like `<Provider>{() => routes}</Provider>` won’t work. Due to the way context works in React 0.13, it’s important that the `<Provider>` children are *created* inside that function. Just referencing an outside variable doesn’t do the trick. Instead of `<Provider>{() => routes}</Provider>`, write `<Provider>{createRoutes}</Provider>` where `createRoutes()` is a function that actually *creates* (and returns) the route configuration. | ||
### Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. This usually means that you're trying to add a ref to a component that doesn't have an owner | ||
If you’re using React for web, this usually means you have a [duplicate React](https://medium.com/@dan_abramov/two-weird-tricks-that-fix-react-7cf9bbdef375). Follow the linked instructions to fix this. | ||
If you’re using React Native, make sure you’re importing `react-redux/native` both for `<Provider>` and any `connect()` call. Importing from `react-redux` will not work on React Native. | ||
## License | ||
MIT |
@@ -174,6 +174,6 @@ import expect from 'expect'; | ||
it('should replace just the reducer when receiving a new store in props', () => { | ||
it('should warn once when receiving a new store in props', () => { | ||
const store1 = createStore((state = 10) => state + 1); | ||
const store2 = createStore((state = 10) => state * 2); | ||
const spy = expect.createSpy(() => ({})); | ||
const store3 = createStore((state = 10) => state * state); | ||
@@ -196,16 +196,24 @@ class ProviderContainer extends Component { | ||
child.context.store.subscribe(spy); | ||
child.context.store.dispatch({}); | ||
expect(spy.calls.length).toEqual(1); | ||
expect(child.context.store.getState()).toEqual(12); | ||
let spy = expect.spyOn(console, 'error'); | ||
container.setState({ store: store2 }); | ||
expect(spy.calls.length).toEqual(2); | ||
expect(child.context.store.getState()).toEqual(24); | ||
spy.destroy(); | ||
child.context.store.dispatch({}); | ||
expect(spy.calls.length).toEqual(3); | ||
expect(child.context.store.getState()).toEqual(48); | ||
expect(child.context.store.getState()).toEqual(11); | ||
expect(spy.calls.length).toBe(1); | ||
expect(spy.calls[0].arguments[0]).toBe( | ||
'<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/rackt/react-redux/releases/' + | ||
'tag/v2.0.0 for the migration instructions.' | ||
); | ||
spy = expect.spyOn(console, 'error'); | ||
container.setState({ store: store3 }); | ||
spy.destroy(); | ||
expect(child.context.store.getState()).toEqual(11); | ||
expect(spy.calls.length).toBe(0); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
480
1
115214
2148