Last active
July 21, 2017 21:22
-
-
Save glortho/94876497b4b08caed0333895c30f4c8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { users } from './api_decorator'; | |
const UserDetail = users(({ users }) => { | |
const user = users.list().data[0]; | |
if ( user ) { | |
const detail = users.get( user.id ); | |
return ( | |
<div style={{ width: '48%' }}> | |
{ | |
detail.error ? | |
`Error: ${ JSON.stringify( detail.error ) }` : | |
detail.isPending ? | |
`Loading...` : | |
<code style={{ width: '300px' }}>{ JSON.stringify( detail.data ).replace( /,/g, ', ') }</code> | |
} | |
</div> | |
); | |
} else { | |
return <div>Waiting for users...</div>; | |
} | |
}); | |
export default UserDetail; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment