Created
September 11, 2019 20:26
-
-
Save pablohpsilva/19e5f71a021c97df6f6ee0206eda1d26 to your computer and use it in GitHub Desktop.
sample medium UiAvatar.tsx
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 React, { useContext, useCallback } from 'react' | |
import { useQuery } from 'react-apollo' | |
import { SomeEntity } from 'dh-apollo-entities' | |
import { UiAvatar } from 'dh-react-ui' | |
import { OurContextAPI } from '@/context' | |
const SmartAvatar = (props) => { | |
const { data, loading } = useQuery(SomeEntity.req, { variables: { d: props.d } }) | |
const { Link, generateContextLinks } = useContext(OurContextAPI) | |
return loading ? | |
<UiAvatar placeholder /> : | |
( | |
<Link {...generateContextLinks()}> | |
<UiAvatar | |
{...data} | |
/> | |
</Link> | |
) | |
} | |
export default SmartAvatar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment