redux-zero
Advanced tools
Comparing version 5.0.4 to 5.0.5
# Changelog | ||
### 5.0.5 | ||
- Fixed connect in preact bindings to call the `mapStateToProps` function when the component props change, | ||
not just when the state store changes | ||
### 5.0.4 | ||
@@ -4,0 +9,0 @@ |
{ | ||
"name": "redux-zero", | ||
"version": "5.0.4", | ||
"version": "5.0.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/redux-zero.js", |
import { Component } from "preact"; | ||
export declare class Connect extends Component<any, {}> { | ||
unsubscribe: any; | ||
state: any; | ||
actions: { | ||
[x: string]: (...args: any[]) => void | Promise<void>; | ||
}; | ||
actions: any; | ||
constructor(props: any, context: any); | ||
componentWillMount(): void; | ||
componentWillUnmount(): void; | ||
getProps(): any; | ||
componentWillReceiveProps(nextProps: any, nextContext: any): void; | ||
getProps(props: any, context: any): any; | ||
getActions(): { | ||
@@ -12,0 +11,0 @@ [x: string]: (...args: any[]) => void | Promise<void>; |
@@ -89,8 +89,6 @@ 'use strict'; | ||
__extends(Connect, _super); | ||
function Connect() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.state = _this.getProps(); | ||
_this.actions = _this.getActions(); | ||
function Connect(props, context) { | ||
var _this = _super.call(this, props, context) || this; | ||
_this.update = function () { | ||
var mapped = _this.getProps(); | ||
var mapped = _this.getProps(_this.props, _this.context); | ||
if (!shallowEqual(mapped, _this.state)) { | ||
@@ -100,2 +98,4 @@ _this.setState(mapped); | ||
}; | ||
_this.state = _this.getProps(props, context); | ||
_this.actions = _this.getActions(); | ||
return _this; | ||
@@ -109,7 +109,13 @@ } | ||
}; | ||
Connect.prototype.getProps = function () { | ||
var mapToProps = this.props.mapToProps; | ||
var state = (this.context.store && this.context.store.getState()) || {}; | ||
return mapToProps ? mapToProps(state, this.props) : state; | ||
Connect.prototype.componentWillReceiveProps = function (nextProps, nextContext) { | ||
var mapped = this.getProps(nextProps, nextContext); | ||
if (!shallowEqual(mapped, this.state)) { | ||
this.setState(mapped); | ||
} | ||
}; | ||
Connect.prototype.getProps = function (props, context) { | ||
var mapToProps = props.mapToProps; | ||
var state = (context.store && context.store.getState()) || {}; | ||
return mapToProps ? mapToProps(state, props) : state; | ||
}; | ||
Connect.prototype.getActions = function () { | ||
@@ -116,0 +122,0 @@ var actions = this.props.actions; |
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],n):n(t["redux-zero"]={},t.preact)}(this,function(t,i){"use strict";var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r])})(t,n)};function p(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var s=function(){return(s=Object.assign||function(t){for(var n,r=1,e=arguments.length;r<e;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)};var r,n=(p(o,r=i.Component),o.prototype.componentWillMount=function(){this.unsubscribe=this.context.store.subscribe(this.update)},o.prototype.componentWillUnmount=function(){this.unsubscribe(this.update)},o.prototype.getProps=function(){var t=this.props.mapToProps,n=this.context.store&&this.context.store.getState()||{};return t?t(n,this.props):n},o.prototype.getActions=function(){return function(o,i,t){function n(e){r[e]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=o[e];return"function"==typeof i.middleware?i.middleware(i,r,t):function(t,n){if(null!=n){if(n.then)return n.then(t.setState);t.setState(n)}}(i,r.apply(void 0,[i.getState()].concat(t)))}}o="function"==typeof o?o(i,t):o;var r={};for(var e in o)n(e);return r}(this.props.actions,this.context.store,this.props)},o.prototype.render=function(t,n,r){var e=t.children,o=r.store;return(e&&e[0]||e)(s({store:o},n,this.actions))},o);function o(){var n=null!==r&&r.apply(this,arguments)||this;return n.state=n.getProps(),n.actions=n.getActions(),n.update=function(){var t=n.getProps();!function(t,n){for(var r in t)if(t[r]!==n[r])return!1;for(var r in n)if(!(r in t))return!1;return!0}(t,n.state)&&n.setState(t)},n}var u=n;var c,a=(p(f,c=i.Component),f.prototype.getChildContext=function(){return{store:this.props.store}},f.prototype.render=function(){return this.props.children&&this.props.children[0]||this.props.children},f);function f(){return null!==c&&c.apply(this,arguments)||this}t.connect=function(e,o){return void 0===o&&(o={}),function(r){return p(t,n=i.Component),t.prototype.render=function(){var n=this.props;return i.h(u,s({},n,{mapToProps:e,actions:o}),function(t){return i.h(r,s({},t,n))})},t;function t(){return null!==n&&n.apply(this,arguments)||this}var n}},t.Provider=a,t.Connect=n,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],n):n(t["redux-zero"]={},t.preact)}(this,function(t,i){"use strict";var r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function p(t,n){function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}var s=function(){return(s=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)};function o(t,n){for(var e in t)if(t[e]!==n[e])return!1;for(var e in n)if(!(e in t))return!1;return!0}var u,n=(p(e,u=i.Component),e.prototype.componentWillMount=function(){this.unsubscribe=this.context.store.subscribe(this.update)},e.prototype.componentWillUnmount=function(){this.unsubscribe(this.update)},e.prototype.componentWillReceiveProps=function(t,n){var e=this.getProps(t,n);o(e,this.state)||this.setState(e)},e.prototype.getProps=function(t,n){var e=t.mapToProps,r=n.store&&n.store.getState()||{};return e?e(r,t):r},e.prototype.getActions=function(){return function(o,i,t){function n(r){e[r]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=o[r];return"function"==typeof i.middleware?i.middleware(i,e,t):function(t,n){if(null!=n){if(n.then)return n.then(t.setState);t.setState(n)}}(i,e.apply(void 0,[i.getState()].concat(t)))}}o="function"==typeof o?o(i,t):o;var e={};for(var r in o)n(r);return e}(this.props.actions,this.context.store,this.props)},e.prototype.render=function(t,n,e){var r=t.children,o=e.store;return(r&&r[0]||r)(s({store:o},n,this.actions))},e);function e(t,n){var e=u.call(this,t,n)||this;return e.update=function(){var t=e.getProps(e.props,e.context);o(t,e.state)||e.setState(t)},e.state=e.getProps(t,n),e.actions=e.getActions(),e}var c=n;var a,f=(p(h,a=i.Component),h.prototype.getChildContext=function(){return{store:this.props.store}},h.prototype.render=function(){return this.props.children&&this.props.children[0]||this.props.children},h);function h(){return null!==a&&a.apply(this,arguments)||this}t.connect=function(r,o){return void 0===o&&(o={}),function(e){return p(t,n=i.Component),t.prototype.render=function(){var n=this.props;return i.h(c,s({},n,{mapToProps:r,actions:o}),function(t){return i.h(e,s({},t,n))})},t;function t(){return null!==n&&n.apply(this,arguments)||this}var n}},t.Provider=f,t.Connect=n,Object.defineProperty(t,"__esModule",{value:!0})}); |
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
71023
1021