Skip to content

Instantly share code, notes, and snippets.

@glortho
Last active July 21, 2017 21:26
Show Gist options
  • Save glortho/5acfa73fc11dbae42c21dd3fb5810fee to your computer and use it in GitHub Desktop.
Save glortho/5acfa73fc11dbae42c21dd3fb5810fee to your computer and use it in GitHub Desktop.
import React from 'react';
import { Api } from 'jetset';
function Users({ users }) {
return (
<div>
{ users.list().isPending ?
<span>Loading...</span>
:
<span>
{users.list().data.map(({ data: user }) =>
<div key={ user.get( 'id' ) }>
<span>{ user.get( 'name' ) }</span>
</div>
)}
</span>
}
</div>
);
}
export default function ApiImmutableExample() {
return (
<Api immutable={ true } url="https://jsonplaceholder.typicode.com" users="/users">
<Users />
</Api>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment