Last active
August 28, 2018 20:43
-
-
Save jbyttow/cdf9a45d8ee5c2659f2b091a3c50b938 to your computer and use it in GitHub Desktop.
Nion Example
This file contains 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 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