Socket
Socket
Sign inDemoInstall

react-redux

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-redux - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

LICENSE.md

116

dist/react-redux.js

@@ -7,5 +7,5 @@ (function webpackUniversalModuleDefinition(root, factory) {

else if(typeof exports === 'object')
exports["ReduxReact"] = factory(require("react"));
exports["ReactRedux"] = factory(require("react"));
else
root["ReduxReact"] = factory(root["React"]);
root["ReactRedux"] = factory(root["React"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_12__) {

@@ -192,2 +192,4 @@ return /******/ (function(modules) { // webpackBootstrap

return (function (_Component) {
_inherits(ConnectorDecorator, _Component);
function ConnectorDecorator() {

@@ -199,4 +201,2 @@ _classCallCheck(this, ConnectorDecorator);

_inherits(ConnectorDecorator, _Component);
ConnectorDecorator.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {

@@ -281,9 +281,2 @@ return !_utilsShallowEqualScalar2['default'](this.props, nextProps);

return (function (_Component) {
function Connector(props, context) {
_classCallCheck(this, Connector);
_Component.call(this, props, context);
this.state = this.selectState(props, context);
}
_inherits(Connector, _Component);

@@ -305,2 +298,32 @@

_createClass(Connector, null, [{
key: 'contextTypes',
value: {
store: storeShape.isRequired
},
enumerable: true
}, {
key: 'propTypes',
value: {
children: PropTypes.func.isRequired,
select: PropTypes.func.isRequired
},
enumerable: true
}, {
key: 'defaultProps',
value: {
select: function select(state) {
return state;
}
},
enumerable: true
}]);
function Connector(props, context) {
_classCallCheck(this, Connector);
_Component.call(this, props, context);
this.state = this.selectState(props, context);
}
Connector.prototype.componentDidMount = function componentDidMount() {

@@ -323,3 +346,3 @@ this.unsubscribe = this.context.store.subscribe(this.handleChange.bind(this));

Connector.prototype.handleChange = function handleChange() {
var props = arguments[0] === undefined ? this.props : arguments[0];
var props = arguments.length <= 0 || arguments[0] === undefined ? this.props : arguments[0];

@@ -349,25 +372,2 @@ var nextState = this.selectState(props, this.context);

_createClass(Connector, null, [{
key: 'contextTypes',
value: {
store: storeShape.isRequired
},
enumerable: true
}, {
key: 'propTypes',
value: {
children: PropTypes.func.isRequired,
select: PropTypes.func.isRequired
},
enumerable: true
}, {
key: 'defaultProps',
value: {
select: function select(state) {
return state;
}
},
enumerable: true
}]);
return Connector;

@@ -407,2 +407,4 @@ })(Component);

return (function (_Component) {
_inherits(ProviderDecorator, _Component);
function ProviderDecorator() {

@@ -414,4 +416,2 @@ _classCallCheck(this, ProviderDecorator);

_inherits(ProviderDecorator, _Component);
ProviderDecorator.prototype.render = function render() {

@@ -476,2 +476,22 @@ var _this = this;

return (function (_Component) {
_inherits(Provider, _Component);
Provider.prototype.getChildContext = function getChildContext() {
return { store: this.state.store };
};
_createClass(Provider, null, [{
key: 'childContextTypes',
value: {
store: storeShape.isRequired
},
enumerable: true
}, {
key: 'propTypes',
value: {
children: PropTypes.func.isRequired
},
enumerable: true
}]);
function Provider(props, context) {

@@ -484,8 +504,2 @@ _classCallCheck(this, Provider);

_inherits(Provider, _Component);
Provider.prototype.getChildContext = function getChildContext() {
return { store: this.state.store };
};
Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {

@@ -507,16 +521,2 @@ var store = this.state.store;

_createClass(Provider, null, [{
key: 'childContextTypes',
value: {
store: storeShape.isRequired
},
enumerable: true
}, {
key: 'propTypes',
value: {
children: PropTypes.func.isRequired
},
enumerable: true
}]);
return Provider;

@@ -651,3 +651,3 @@ })(Component);

var invariant = function(condition, format, a, b, c, d, e, f) {
if ((undefined) !== 'production') {
if (true) {
if (format === undefined) {

@@ -654,0 +654,0 @@ throw new Error('invariant requires an error message argument');

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReduxReact=t(require("react")):e.ReduxReact=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(12),u=r(o),i=n(3),a=r(i),c=a.default(u.default),s=c.Provider,l=c.Connector,f=c.provide,p=c.connect;t.Provider=s,t.Connector=l,t.provide=f,t.connect=p},function(e,t){"use strict";function n(e){return e.shape({subscribe:e.func.isRequired,dispatch:e.func.isRequired,getState:e.func.isRequired})}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e){return e.displayName||e.name||"Component"}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=i.default(e),n=l.default(e),r=c.default(e,t),o=p.default(e,n);return{Provider:t,Connector:n,provide:r,connect:o}}t.__esModule=!0,t.default=o;var u=n(7),i=r(u),a=n(6),c=r(a),s=n(5),l=r(s),f=n(4),p=r(f);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e,t){var n=e.Component;return function(r){return function(i){return function(n){function s(){o(this,s),n.apply(this,arguments)}return u(s,n),s.prototype.shouldComponentUpdate=function(e){return!p.default(this.props,e)},s.prototype.render=function(){var n=this;return e.createElement(t,{select:function(e){return r(e,n.props)}},function(t){return e.createElement(i,a({},t,n.props))})},c(s,null,[{key:"displayName",value:"Connector("+l.default(i)+")",enumerable:!0},{key:"DecoratedComponent",value:i,enumerable:!0}]),s}(n)}}}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var s=n(2),l=r(s),f=n(10),p=r(f);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){var t=e.Component,n=e.PropTypes,r=l.default(n);return function(e){function t(n,r){o(this,t),e.call(this,n,r),this.state=this.selectState(n,r)}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){return!this.isSliceEqual(this.state.slice,t.slice)||!p.default(this.props,e)},t.prototype.isSliceEqual=function(e,t){var n=e===t;return n?!0:"object"!=typeof e||"object"!=typeof t?n:p.default(e,t)},t.prototype.componentDidMount=function(){this.unsubscribe=this.context.store.subscribe(this.handleChange.bind(this)),this.handleChange()},t.prototype.componentWillReceiveProps=function(e){e.select!==this.props.select&&this.handleChange(e)},t.prototype.componentWillUnmount=function(){this.unsubscribe()},t.prototype.handleChange=function(){var e=void 0===arguments[0]?this.props:arguments[0],t=this.selectState(e,this.context);this.isSliceEqual(this.state.slice,t.slice)||this.setState(t)},t.prototype.selectState=function(e,t){var n=t.store.getState(),r=e.select(n);return b.default(y.default(r),"The return value of `select` prop must be an object. Instead received %s.",r),{slice:r}},t.prototype.render=function(){var e=this.props.children,t=this.state.slice,n=this.context.store.dispatch;return e(a({dispatch:n},t))},c(t,null,[{key:"contextTypes",value:{store:r.isRequired},enumerable:!0},{key:"propTypes",value:{children:n.func.isRequired,select:n.func.isRequired},enumerable:!0},{key:"defaultProps",value:{select:function(e){return e}},enumerable:!0}]),t}(t)}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var s=n(1),l=r(s),f=n(9),p=r(f),d=n(8),y=r(d),h=n(11),b=r(h);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e,t){var n=e.Component;return function(r){return function(i){return function(n){function c(){o(this,c),n.apply(this,arguments)}return u(c,n),c.prototype.render=function(){var n=this;return e.createElement(t,{store:r},function(){return e.createElement(i,n.props)})},a(c,null,[{key:"displayName",value:"Provider("+s.default(i)+")",enumerable:!0},{key:"DecoratedComponent",value:i,enumerable:!0}]),c}(n)}}}t.__esModule=!0;var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var c=n(2),s=r(c);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){var t=e.Component,n=e.PropTypes,r=s.default(n);return function(e){function t(n,r){o(this,t),e.call(this,n,r),this.state={store:n.store}}return u(t,e),t.prototype.getChildContext=function(){return{store:this.state.store}},t.prototype.componentWillReceiveProps=function(e){var t=this.state.store,n=e.store;if(t!==n){var r=n.getReducer();t.replaceReducer(r)}},t.prototype.render=function(){var e=this.props.children;return e()},a(t,null,[{key:"childContextTypes",value:{store:r.isRequired},enumerable:!0},{key:"propTypes",value:{children:n.func.isRequired},enumerable:!0}]),t}(t)}t.__esModule=!0;var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var c=n(1),s=r(c);e.exports=t.default},function(e,t){"use strict";function n(e){return e?"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype:!1}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e,t){if(e===t)return!0;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<n.length;u++)if(!o.call(t,n[u])||e[n[u]]!==t[n[u]])return!1;return!0}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<n.length;u++){if(!o.call(t,n[u]))return!1;var i=e[n[u]],a=t[n[u]];if(i!==a||"object"==typeof i||"object"==typeof a)return!1}return!0}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t,n){"use strict";var r=function(e,t,n,r,o,u,i,a){if(!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,r,o,u,i,a],l=0;c=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return s[l++]}))}throw c.framesToPop=1,c}};e.exports=r},function(t,n){t.exports=e}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactRedux=t(require("react")):e.ReactRedux=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(12),u=r(o),i=n(3),a=r(i),c=a.default(u.default),s=c.Provider,l=c.Connector,f=c.provide,p=c.connect;t.Provider=s,t.Connector=l,t.provide=f,t.connect=p},function(e,t){"use strict";function n(e){return e.shape({subscribe:e.func.isRequired,dispatch:e.func.isRequired,getState:e.func.isRequired})}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e){return e.displayName||e.name||"Component"}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=i.default(e),n=l.default(e),r=c.default(e,t),o=p.default(e,n);return{Provider:t,Connector:n,provide:r,connect:o}}t.__esModule=!0,t.default=o;var u=n(7),i=r(u),a=n(6),c=r(a),s=n(5),l=r(s),f=n(4),p=r(f);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e,t){var n=e.Component;return function(r){return function(i){return function(n){function s(){o(this,s),n.apply(this,arguments)}return u(s,n),s.prototype.shouldComponentUpdate=function(e){return!p.default(this.props,e)},s.prototype.render=function(){var n=this;return e.createElement(t,{select:function(e){return r(e,n.props)}},function(t){return e.createElement(i,a({},t,n.props))})},c(s,null,[{key:"displayName",value:"Connector("+l.default(i)+")",enumerable:!0},{key:"DecoratedComponent",value:i,enumerable:!0}]),s}(n)}}}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var s=n(2),l=r(s),f=n(10),p=r(f);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){var t=e.Component,n=e.PropTypes,r=l.default(n);return function(e){function t(n,r){o(this,t),e.call(this,n,r),this.state=this.selectState(n,r)}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){return!this.isSliceEqual(this.state.slice,t.slice)||!p.default(this.props,e)},t.prototype.isSliceEqual=function(e,t){var n=e===t;return n?!0:"object"!=typeof e||"object"!=typeof t?n:p.default(e,t)},c(t,null,[{key:"contextTypes",value:{store:r.isRequired},enumerable:!0},{key:"propTypes",value:{children:n.func.isRequired,select:n.func.isRequired},enumerable:!0},{key:"defaultProps",value:{select:function(e){return e}},enumerable:!0}]),t.prototype.componentDidMount=function(){this.unsubscribe=this.context.store.subscribe(this.handleChange.bind(this)),this.handleChange()},t.prototype.componentWillReceiveProps=function(e){e.select!==this.props.select&&this.handleChange(e)},t.prototype.componentWillUnmount=function(){this.unsubscribe()},t.prototype.handleChange=function(){var e=arguments.length<=0||void 0===arguments[0]?this.props:arguments[0],t=this.selectState(e,this.context);this.isSliceEqual(this.state.slice,t.slice)||this.setState(t)},t.prototype.selectState=function(e,t){var n=t.store.getState(),r=e.select(n);return b.default(y.default(r),"The return value of `select` prop must be an object. Instead received %s.",r),{slice:r}},t.prototype.render=function(){var e=this.props.children,t=this.state.slice,n=this.context.store.dispatch;return e(a({dispatch:n},t))},t}(t)}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var s=n(1),l=r(s),f=n(9),p=r(f),d=n(8),y=r(d),h=n(11),b=r(h);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e,t){var n=e.Component;return function(r){return function(i){return function(n){function c(){o(this,c),n.apply(this,arguments)}return u(c,n),c.prototype.render=function(){var n=this;return e.createElement(t,{store:r},function(){return e.createElement(i,n.props)})},a(c,null,[{key:"displayName",value:"Provider("+s.default(i)+")",enumerable:!0},{key:"DecoratedComponent",value:i,enumerable:!0}]),c}(n)}}}t.__esModule=!0;var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var c=n(2),s=r(c);e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){var t=e.Component,n=e.PropTypes,r=s.default(n);return function(e){function t(n,r){o(this,t),e.call(this,n,r),this.state={store:n.store}}return u(t,e),t.prototype.getChildContext=function(){return{store:this.state.store}},a(t,null,[{key:"childContextTypes",value:{store:r.isRequired},enumerable:!0},{key:"propTypes",value:{children:n.func.isRequired},enumerable:!0}]),t.prototype.componentWillReceiveProps=function(e){var t=this.state.store,n=e.store;if(t!==n){var r=n.getReducer();t.replaceReducer(r)}},t.prototype.render=function(){var e=this.props.children;return e()},t}(t)}t.__esModule=!0;var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.default=i;var c=n(1),s=r(c);e.exports=t.default},function(e,t){"use strict";function n(e){return e?"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype:!1}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e,t){if(e===t)return!0;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<n.length;u++)if(!o.call(t,n[u])||e[n[u]]!==t[n[u]])return!1;return!0}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t){"use strict";function n(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=Object.prototype.hasOwnProperty,u=0;u<n.length;u++){if(!o.call(t,n[u]))return!1;var i=e[n[u]],a=t[n[u]];if(i!==a||"object"==typeof i||"object"==typeof a)return!1}return!0}t.__esModule=!0,t.default=n,e.exports=t.default},function(e,t,n){"use strict";var r=function(e,t,n,r,o,u,i,a){if(!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,r,o,u,i,a],l=0;c=new Error("Invariant Violation: "+t.replace(/%s/g,function(){return s[l++]}))}throw c.framesToPop=1,c}};e.exports=r},function(t,n){t.exports=e}])});

@@ -15,3 +15,3 @@ 'use strict';

function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

@@ -32,2 +32,4 @@ var _utilsGetDisplayName = require('../utils/getDisplayName');

return (function (_Component) {
_inherits(ConnectorDecorator, _Component);
function ConnectorDecorator() {

@@ -39,4 +41,2 @@ _classCallCheck(this, ConnectorDecorator);

_inherits(ConnectorDecorator, _Component);
ConnectorDecorator.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {

@@ -43,0 +43,0 @@ return !_utilsShallowEqualScalar2['default'](this.props, nextProps);

@@ -15,3 +15,3 @@ 'use strict';

function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

@@ -41,9 +41,2 @@ var _utilsCreateStoreShape = require('../utils/createStoreShape');

return (function (_Component) {
function Connector(props, context) {
_classCallCheck(this, Connector);
_Component.call(this, props, context);
this.state = this.selectState(props, context);
}
_inherits(Connector, _Component);

@@ -65,2 +58,32 @@

_createClass(Connector, null, [{
key: 'contextTypes',
value: {
store: storeShape.isRequired
},
enumerable: true
}, {
key: 'propTypes',
value: {
children: PropTypes.func.isRequired,
select: PropTypes.func.isRequired
},
enumerable: true
}, {
key: 'defaultProps',
value: {
select: function select(state) {
return state;
}
},
enumerable: true
}]);
function Connector(props, context) {
_classCallCheck(this, Connector);
_Component.call(this, props, context);
this.state = this.selectState(props, context);
}
Connector.prototype.componentDidMount = function componentDidMount() {

@@ -83,3 +106,3 @@ this.unsubscribe = this.context.store.subscribe(this.handleChange.bind(this));

Connector.prototype.handleChange = function handleChange() {
var props = arguments[0] === undefined ? this.props : arguments[0];
var props = arguments.length <= 0 || arguments[0] === undefined ? this.props : arguments[0];

@@ -109,25 +132,2 @@ var nextState = this.selectState(props, this.context);

_createClass(Connector, null, [{
key: 'contextTypes',
value: {
store: storeShape.isRequired
},
enumerable: true
}, {
key: 'propTypes',
value: {
children: PropTypes.func.isRequired,
select: PropTypes.func.isRequired
},
enumerable: true
}, {
key: 'defaultProps',
value: {
select: function select(state) {
return state;
}
},
enumerable: true
}]);
return Connector;

@@ -134,0 +134,0 @@ })(Component);

@@ -13,3 +13,3 @@ 'use strict';

function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

@@ -26,2 +26,4 @@ var _utilsGetDisplayName = require('../utils/getDisplayName');

return (function (_Component) {
_inherits(ProviderDecorator, _Component);
function ProviderDecorator() {

@@ -33,4 +35,2 @@ _classCallCheck(this, ProviderDecorator);

_inherits(ProviderDecorator, _Component);
ProviderDecorator.prototype.render = function render() {

@@ -37,0 +37,0 @@ var _this = this;

@@ -13,3 +13,3 @@ 'use strict';

function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

@@ -27,2 +27,22 @@ var _utilsCreateStoreShape = require('../utils/createStoreShape');

return (function (_Component) {
_inherits(Provider, _Component);
Provider.prototype.getChildContext = function getChildContext() {
return { store: this.state.store };
};
_createClass(Provider, null, [{
key: 'childContextTypes',
value: {
store: storeShape.isRequired
},
enumerable: true
}, {
key: 'propTypes',
value: {
children: PropTypes.func.isRequired
},
enumerable: true
}]);
function Provider(props, context) {

@@ -35,8 +55,2 @@ _classCallCheck(this, Provider);

_inherits(Provider, _Component);
Provider.prototype.getChildContext = function getChildContext() {
return { store: this.state.store };
};
Provider.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {

@@ -58,16 +72,2 @@ var store = this.state.store;

_createClass(Provider, null, [{
key: 'childContextTypes',
value: {
store: storeShape.isRequired
},
enumerable: true
}, {
key: 'propTypes',
value: {
children: PropTypes.func.isRequired
},
enumerable: true
}]);
return Provider;

@@ -74,0 +74,0 @@ })(Component);

{
"name": "react-redux",
"version": "0.2.2",
"version": "0.3.0",
"description": "Redux bindings for React",
"main": "./lib/index.js",
"scripts": {
"browser": "scripts/browser",
"build": "scripts/build",
"clean": "scripts/clean",
"lint": "scripts/lint",
"prepublish": "scripts/prepublish",
"test": "scripts/test",
"test:watch": "scripts/test-watch",
"test:cov": "scripts/test-cov"
"build:lib": "babel src --out-dir lib",
"build:umd": "webpack src/index.js dist/react-redux.js --config webpack.config.development.js",
"build:umd:min": "webpack src/index.js dist/react-redux.min.js --config webpack.config.production.js",
"build": "npm run build:lib && npm run build:umd && npm run build:umd:min",
"clean": "rimraf lib dist coverage",
"lint": "eslint src test",
"prepublish": "npm run clean && npm run build",
"test": "mocha --compilers js:babel/register --recursive",
"test:watch": "npm test -- --watch",
"test:cov": "babel-node ./node_modules/isparta/bin/isparta cover ./node_modules/mocha/bin/_mocha -- --recursive"
},

@@ -39,3 +41,3 @@ "repository": {

"babel": "^5.5.8",
"babel-core": "5.6.15",
"babel-core": "5.6.18",
"babel-eslint": "^3.1.15",

@@ -46,4 +48,5 @@ "babel-loader": "^5.1.4",

"eslint-plugin-react": "^2.3.0",
"expect": "^1.6.0",
"istanbul": "^0.3.15",
"expect": "^1.8.0",
"isparta": "^3.0.3",
"istanbul": "^0.3.17",
"jsdom": "~5.4.3",

@@ -50,0 +53,0 @@ "mocha": "^2.2.5",

react-redux
=========================
React bindings for Redux.
Docs are work in progress.
Higher-order React components for [Redux](https://github.com/gaearon/redux).
Requires React >= 0.13
What you get from `react-redux` is for React.
For React Native, import from `react-redux/native` instead.
>**Note: There is a project called “redux-react” on NPM that is completely unrelated to the official bindings. This documentation (and any other official Redux documentation) is for `react-redux`.**
- [Quick Start](#quick-start)
- [Recommended API](#recommended-api)
- [`connect`](#connect)
- [`Provider`](#provider)
- [Deprecated API](#deprecated-api)
- [`Connector`](#connector)
- [`provide`](#provide)
## Quick Start
React bindings for Redux embrace the idea of [dividing “smart” and “dumb” components](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0).
It is advisable that only top-level components of your app (such as route handlers, for example) are aware of Redux. Components below them should be “dumb” and receive all data via props.
<center>
<table>
<thead>
<tr>
<th></th>
<th>Location</th>
<th>Use React-Redux</th>
<th>To read data, they</th>
<th>To change data, they</th>
</tr>
</thead>
<tbody>
<tr>
<td>“Smart” Components</td>
<td>Top level, route handlers</td>
<td>Yes</th>
<td>Subscribe to Redux state</td>
<td>Dispatch Redux actions</td>
</tr>
<tr>
<td>“Dumb” Components</td>
<td>Middle and leaf components</td>
<td>No</th>
<td>Read data from props</td>
<td>Invoke callbacks from props</td>
</tr>
</tbody>
</table>
</center>
### “Dumb” component is unaware of Redux
Let’s say we have a `<Counter />` “dumb” component with a number `counter` prop, and an `increment` function prop that it will call when user presses an “Increment” button:
```js
import { Component } from 'react';
export default class Counter extends Component {
render() {
return (
<button onClick={this.props.increment}>
{this.props.counter}
</button>
);
}
}
```
### “Smart” component is `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. With the current API, we’ll need to add an intermediate `CounterContainer` component, but we will soon make `connect` API more powerful so this won’t be required. The `connect()` function lets you specify *which exactly* state from the Redux store your component wants to track. This lets you subscribe on any level of granularity.
Our `CounterContainer` that’s necessary to hook `Counter` up to a Redux store looks like this:
(This will be much less verbose in the next versions.)
```js
import { Component } from 'react';
import { connect } from 'react-redux';
// Assuming this is our “dumb” counter
import Counter from '../components/Counter';
// Assuming these are Redux action creators
import { increment } from './actionCreators';
function select(state) {
// Which part of the Redux global state does our component want to receive as props?
return {
counter: state.counter
};
}
class CounterContainer extends Component {
render() {
// connect() call below will inject `dispatch` and
// every key returned by `select` as props into our container:
const { dispatch, counter } = this.props;
// render our “dumb” component, hooking up state to data props
// and using “dispatch action produced by this action creator” as callbacks.
// this is a “bridge” between a Redux-aware world above and Redux-unaware world below.
return (
<Counter counter={counter}
increment={() => dispatch(increment())} />
);
}
}
// Don't forget to actually use connect!
export default connect(select)(CounterContainer);
// You might have noticed that we used parens twice.
// This is called partial applications, and it lets people
// use ES7 decorator proposal syntax:
//
// @connect(select)
// export default class CounterContainer { ... }
//
// Don’t forget decorators are experimental! And they
// desugar to function calls anyway as example above demonstrates.
```
As you can see, action creators in Redux just return actions, but we need to manually “bind” them to the `dispatch` function for our Redux store. Why don’t we bind action creators to a store right away? This is because of the so-called “universal” apps that need to render on the server. They would have a different store instance for every request, so we don’t know the store instance during the definition!
### Binding many action creators
Binding can get cumbersome, so Redux provides a `bindActionCreators` helper to turn many action creator methods into an object with methods called the same, but bound to a particular `dispatch` function:
```js
import { Component } from 'react';
import { connect } from 'react-redux';
// A helper provided by Redux!
import { bindActionCreators } from 'redux';
// Import many action creators as a single object (like `require('./actionCreators')` in CommonJS)
import * as CounterActionCreators from './actionCreators';
import Counter from '../components/Counter';
function select(state) {
return {
counter: state.counter
};
}
class CounterContainer extends Component {
render() {
const { dispatch, counter } = this.props;
// This time, we use `bindActionCreators` to bind many action creators
// to a particular dispatch function from our Redux store.
return (
<Counter counter={counter}
{...bindActionCreators(CounterActionCreators, dispatch)} />
);
}
}
// Don't forget to actually use connect!
export default connect(select)(CounterContainer);
```
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.
### 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.
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 with 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.
```js
import { Component } from 'react';
import { Provider } from 'react-redux';
class App extends Component {
render() {
// ...
}
}
const targetEl = document.getElementById('root');
React.render((
<Provider store={store}>
{() => <App />}
</Provider>
), targetEl);
// or, if you use React Router 0.13,
// Router.run(routes, Router.HistoryLocation, (Handler) => {
// React.render(
// <Provider store={store}>
// {() => <Handler />}
// </Provider>,
// targetEl
// );
// });
// or, if you use React Router 1.0,
// React.render(
// <Provider store={store}>
// {() => <Router history={history}>...</Router>}
// </Provider>,
// targetEl
// );
```
## Recommended API
### `connect`
```js
export default connect(select)(MyComponent);
```
Returns a component class that injects the Redux Store’s `dispatch` as a prop into `Component` so it can dispatch Redux actions.
The returned component also subscribes to the updates of Redux store. Any time the state changes, it calls the `select` function passed to it. The selector function takes a single argument of the entire Redux store’s state and returns an object to be passed as props. Use [reselect](https://github.com/faassen/reselect) to efficiently compose selectors and memoize derived data.
Both `dispatch` and every property returned by `select` will be provided to your `Component` as `props`.
It is the responsibility of a Smart Component to bind action creators to the given `dispatch` function and pass those
bound creators to Dumb Components. Redux provides a `bindActionCreators` to streamline the process of binding action
creators to the dispatch function.
**To use `connect()`, the root component of your app must be wrapped into `<Provider>{() => ... }</Provider>` before being rendered.**
See the usage example in the quick start above.
### `Provider`
```js
<Provider store={store}>
{() => <MyRootComponent>}
</Provider>
```
The `Provider` component takes a `store` prop and a [function as a child](#child-must-be-a-function) with your root
component. The `store` is then passed to the child via React's `context`. This is the entry point for Redux and must be
present in order to use the `Connector` component.
## Deprecated API
### `Connector`
>**Note**
>Deprecated. Use `connect()` instead.
```js
<Connector select={fn}>
{props => <MyComponent {...props} />}
</Connector>
```
Similar to `Provider`, the `Connector` expects a single [function as a child](#child-must-be-a-function) and a function
as the `select` prop. The selector function takes a single argument of the entire root store and returns an object to be
passed as properties to the child. In addition to the properties returned by the selector, a `dispatch` function is
passed to the child for dispatching actions.
It is the responsibility of a Smart Component to bind action creators to the given `dispatch` function and pass those
bound creators to Dumb Components. Redux provides a `bindActionCreators` to streamline the process of binding action
creators to the dispatch function.
We don’t recommend its use anymore because it’s not as flexible as `connect()` and has some performance implications for more complex scenarios.
### `provide`
>**Note**
>Deprecated. Use `<Provider>` instead.
```js
export default provide(store)(MyRootComponent);
```
This higher-order component provides the same functionality as `<Provider>`. We don’t recommend it anymore because it’s less flexible than `<Provider>` and doesn’t work with [redux-devtools](http://github.com/gaearon/redux-devtools) or server rendering.
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc