Yoctol/async-update-props

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

async-update-props

Greenkeeper badge

NPM version Build Status Test coverage Dependency Status

Async props update HoC for React Component

Install
m install async-update-props
Usage
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);
API
asyncUpdateProps(updater, shouldUpdateWhenReceiveProps)
updater

Required Type: func

shouldUpdateWhenReceiveProps

Optional Type: func Default: () => true

License

MIT © Yoctol


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.