Skip to content

Instantly share code, notes, and snippets.

@pablohpsilva
Created September 11, 2019 20:26
Show Gist options
  • Save pablohpsilva/19e5f71a021c97df6f6ee0206eda1d26 to your computer and use it in GitHub Desktop.
Save pablohpsilva/19e5f71a021c97df6f6ee0206eda1d26 to your computer and use it in GitHub Desktop.
sample medium UiAvatar.tsx
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