react-data-fetching icon indicating copy to clipboard operation
react-data-fetching copied to clipboard

Enable to define different states

Open busypeoples opened this issue 6 years ago • 1 comments

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>
);

busypeoples avatar Jun 29 '18 22:06 busypeoples

Hi @busypeoples! Just saw your PR #22, so let's gather all the discussing there and close this issue when everything will be implemented :)

CharlesMangwa avatar Aug 18 '18 00:08 CharlesMangwa