react-data-fetching
react-data-fetching copied to clipboard
Enable to define different states
Opening up this issue for discussion, maybe this could be interesting. Enable to define different states and render them according to the current state. Check this out example using Tasks f.e. https://codesandbox.io/s/vv92zqqz0l
const App = () => (
<Fetch
url="https://api.github.com/users/octocat"
timeout={5000}
>
{({ result }) => (
{result.cata(
{
notAsked: () => <div>Nothing Loaded</div>,
loading: () => <div>Loading...</div>,
error: error => <div>Something went wrong: {error}</div>,
success: ({ users }) => (
<ul>{users.map(user => <UserComponent key={user.id} {...user} />)}</ul>
)
})
)}
</Fetch>
);
Hi @busypeoples! Just saw your PR #22, so let's gather all the discussing there and close this issue when everything will be implemented :)