1.1.0 • Published 9 years ago
@ubc-farm/async-hoc v1.1.0
async-hoc
A simple higher order component for React, which gets data from a promise when the component mounts and then adds it to a prop once the promise has resolved.
API
asyncHOC() (default export)
asyncHOC(
promiseFunc: () => Promise,
{
?dataProp: string,
?loadingProp: string,
?errorProp: string
}
): HigherOrderComponentpromiseFunc is called without any arguments, and the resulting promise
is awaited and the data is set on the prop with the name dataProp.
dataProp defaults to 'data',
loadingProp defaults to 'loading', and
errorProp defaults to 'error'.