about summary refs log tree commit diff
path: root/src/view/com/util/UserPreviewLink.tsx
blob: 09d230000e3acb181022815e8365e6d91e2738bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {makeProfileLink} from 'lib/routes/links'
import {isWeb} from 'platform/detection'
import React from 'react'
import {StyleProp, ViewStyle} from 'react-native'

import {usePrefetchProfileQuery} from '#/state/queries/profile'

import {Link} from './Link'

interface UserPreviewLinkProps {
  did: string
  handle: string
  style?: StyleProp<ViewStyle>
}
export function UserPreviewLink(
  props: React.PropsWithChildren<UserPreviewLinkProps>,
) {
  const prefetchProfileQuery = usePrefetchProfileQuery()
  return (
    <Link
      onPointerEnter={() => {
        if (isWeb) {
          prefetchProfileQuery(props.did)
        }
      }}
      href={makeProfileLink(props)}
      title={props.handle}
      asAnchor
      style={props.style}>
      {props.children}
    </Link>
  )
}