Used to create props that can be passed to a React Native or web component for creating a custom link.
import { useLinkTo } from 'one'
import { Pressable, Text } from 'react-native'
export default function CustomLinkButton() {
const linkProps = useLinkTo({ href: '/profile' })
return (
<Pressable {...linkProps}>
<Text>Go to Profile</Text>
</Pressable>
)
}
Accepts a single argument of type:
type LinkToProps = {
href: Href
replace?: boolean
}
Note that Href is a string that is typed based on your file system routes.
Returns an object of type:
type LinkToResult = {
href: string
role: 'link'
onPress: (event?: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => void
}
Edit this page on GitHub.