async-update-props
v1.0.2
Published
async props update HoC for React Component
Downloads
9
Maintainers
Readme
async-update-props
Async props update HoC for React Component
Install
$ npm install async-update-props
Usage
import { compose } from 'redux';
import { connect } from 'react-redux';
import asyncUpdateProps from 'async-update-props';
import Page from '../components/Page';
import { fetchDataRequest } from '../actions';
const mapStateToProps = (state) => ({
...
});
const updater = (props) => {
props.fetchDataRequest();
};
const shouldUpdateWhenReceiveProps = () => false;
export default compose(
connect(mapStateToProps, {
fetchDataRequest,
}),
asyncUpdateProps(updater, shouldUpdateWhenReceiveProps)
)(Page);
API
asyncUpdateProps(updater, shouldUpdateWhenReceiveProps)
updater
Required
Type: func
shouldUpdateWhenReceiveProps
Optional
Type: func
Default: () => true
License
MIT © Yoctol