Skip to content

Instantly share code, notes, and snippets.

@glortho
Last active July 21, 2017 21:22
Show Gist options
  • Save glortho/94876497b4b08caed0333895c30f4c8a to your computer and use it in GitHub Desktop.
Save glortho/94876497b4b08caed0333895c30f4c8a to your computer and use it in GitHub Desktop.
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