import React from 'react';
import { storiesOf } from '@storybook/react';
import { DataLoader } from '../src/components/data-loader/DataLoader';
storiesOf('DataLoader', module)
.add('load posts', () => {
function PostLoader(props) {
const loader = async () => {
const wait = (ms, value) => new Promise(resolve => setTimeout(resolve, ms, value))
return await fetch(props.url).then(res => res.json()).then(value => wait(3000, value));
}
return {props.children};
}
return (
{posts => (
Name |
Description |
{posts.map((post, i) => (
{post.title} |
{post.body} |
))}
)}
);
});