data-promiser
v0.1.3
Published
React component that deliver data from promises
Downloads
2
Readme
Data promiser
React component to render data from promises
Usage
Install using yarn
yarn add data-promiser
or with npm
npm install --save data-promiser
Example
import React from 'react'
import DataPromiser from 'data-promiser'
function examplePromiseFn() {
return new Promise((resolve, reject) => {
window.setTimeout(() => {
resolve('SUCCESS')
}, 2000)
})
}
const ExampleComponent = () => (
<div>
<section>
<p>Wait 2 seconds before resolving. </p>
<DataPromiser
promiseFn={examplePromiseFn}
renderData={(data, waiting) => (
<p>{data}</p>
)}
/>
</section>
</div>
)