Name: async-update-props
Owner: YOCTOL INFO INC.
Description: null
Created: 2016-09-15 09:49:18.0
Updated: 2016-11-24 12:14:13.0
Pushed: 2018-01-18 03:13:40.0
Homepage: null
Size: 74
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Async props update HoC for React Component
m install async-update-props
rt { compose } from 'redux';
rt { connect } from 'react-redux';
rt asyncUpdateProps from 'async-update-props';
rt Page from '../components/Page';
rt { fetchDataRequest } from '../actions';
t mapStateToProps = (state) => ({
.
t updater = (props) => {
ops.fetchDataRequest();
t shouldUpdateWhenReceiveProps = () => false;
rt default compose(
nnect(mapStateToProps, {
fetchDataRequest,
,
yncUpdateProps(updater, shouldUpdateWhenReceiveProps)
ge);
If updater returns a promise, setState will be called with resolved value automatically:
rt asyncUpdateProps from 'async-update-props';
rt Page from '../components/Page';
rt * as apis from '../apis';
t updater = () => {
turn apis.fetchDataRequest();
t shouldUpdateWhenReceiveProps = () => false;
rt default asyncUpdateProps(updater, shouldUpdateWhenReceiveProps)(Page);
Required
Type: func
Optional
Type: func
Default: () => true
MIT © Yoctol