react-updating-hoc
v2.3.1
Published
small HOC for implementing update on props changing
Downloads
29
Maintainers
Readme
react-updating-hoc
$ npm install react-updating-hoc recompose react lodash --save
Usage
import React from 'react';
import updating, { callWhen, callWhenPropsAreUpdated, callWhenPropsAreUpdatedDeeply, callWhen } from 'react-updating-hoc';
const SomeComponent = () => (<div>Hello wordl!</div>);
export default updating(
callWhen((props) => Boolean(props.some), (props) => {
// do something useful
}),
callWhenPropsAreUpdated([ 'some', 'any' ], (props) => {
// do something useful
}),
callWhenPropsAreUpdatedDeeply([ 'some', 'any' ], (props) => {
// do something useful
}),
callWhenPropsAreUpdated([ 'some.nested.prop', 'any' ], (props) => { // shallow equality check with lodash get
// do something useful
}, true),
callWhenPropsAreUpdatedDeeply([ 'some.nested.prop', 'any' ], (props) => { // deep equality check with lodash get
// do something useful
}, true)
)(SomeComponent);