Skip to content

Instantly share code, notes, and snippets.

@jbyttow
Last active August 28, 2018 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbyttow/cdf9a45d8ee5c2659f2b091a3c50b938 to your computer and use it in GitHub Desktop.
Save jbyttow/cdf9a45d8ee5c2659f2b091a3c50b938 to your computer and use it in GitHub Desktop.
Nion Example
import nion from 'nion'
@nion({
currentUser: {
endpoint: buildUrl('/api/current-user', { fields: user: ['avatarUrl'] }),
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 && data ?
<Avatar avatarUrl={data.avatarUrl} /> :
null
}
</Card>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment