Skip to content

Instantly share code, notes, and snippets.

@jbyttow
Created August 24, 2018 21:22
Show Gist options
  • Save jbyttow/ef085c0ea767b552805556b99a680009 to your computer and use it in GitHub Desktop.
Save jbyttow/ef085c0ea767b552805556b99a680009 to your computer and use it in GitHub Desktop.
nion example
@nion({
currentUser: {
endpoint: buildUrl('/api/current-user'),
apiType: 'jsonApi'
}
})
class UserContainer extends Component {
render() {
const { request, actions, data } = this.props.nion.currentUser
return (
<Card>
{ request.isLoading ?
<LoadingSpinner /> :
<Button onClick={() => actions.get()}>Load</Button>
}
{ !request.isLoading && currentUser.data ?
<Avatar avatarUrl={currentUser.data.avatarUrl} /> :
null
}
</Card>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment