react-refect
Advanced tools
Comparing version 0.1.0-alpha.7 to 0.1.0-alpha.8
@@ -58,2 +58,19 @@ 'use strict'; | ||
function shallowEqual(a, b) { | ||
/* eslint-disable no-restricted-syntax */ | ||
for (var key in a) { | ||
if ({}.hasOwnProperty.call(a, key) && (!{}.hasOwnProperty.call(b, key) || a[key] !== b[key])) { | ||
return false; | ||
} | ||
} | ||
for (var _key in b) { | ||
if ({}.hasOwnProperty.call(b, _key) && !{}.hasOwnProperty.call(a, _key)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function refect(options) { | ||
@@ -128,2 +145,10 @@ var _class, _temp; | ||
}, { | ||
key: 'shouldComponentUpdate', | ||
value: function shouldComponentUpdate(props, state) { | ||
var finalProps = (state.storeState, props, state.storeAllState); | ||
var thisFinalProps = mapStateToProps(this.state.storeState, this.props, this.state.storeAllState); | ||
return !shallowEqual(finalProps, thisFinalProps); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
@@ -130,0 +155,0 @@ value: function componentWillUnmount() { |
{ | ||
"name": "react-refect", | ||
"version": "0.1.0-alpha.7", | ||
"version": "0.1.0-alpha.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -25,2 +25,19 @@ import React, { Component, PropTypes } from 'react'; | ||
function shallowEqual(a, b) { | ||
/* eslint-disable no-restricted-syntax */ | ||
for (const key in a) { | ||
if ({}.hasOwnProperty.call(a, key) && (!{}.hasOwnProperty.call(b, key) || a[key] !== b[key])) { | ||
return false; | ||
} | ||
} | ||
for (const key in b) { | ||
if ({}.hasOwnProperty.call(b, key) && !{}.hasOwnProperty.call(a, key)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
export default function refect(options) { | ||
@@ -100,2 +117,10 @@ const { mapStateToProps = defaultMapStateToProps, view, initialState } = options; | ||
shouldComponentUpdate(props, state) { | ||
const finalProps = (state.storeState, props, state.storeAllState); | ||
const thisFinalProps = mapStateToProps(this.state.storeState, | ||
this.props, this.state.storeAllState); | ||
return !shallowEqual(finalProps, thisFinalProps); | ||
} | ||
componentWillUnmount() { | ||
@@ -102,0 +127,0 @@ const actions = this.actions; |
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
15110
314