Created
July 25, 2019 02:09
-
-
Save Ifmr24/d102ceddd2864cdfb886dea5e9855ca3 to your computer and use it in GitHub Desktop.
useLinkComponent.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 from 'react' | |
import { Link } from "react-router-dom"; | |
interface useLinkComponentProps{ | |
url: string, | |
} | |
const useLinkComponent: React.SFC<useLinkComponentProps> = ({url, children, ...rest}) => { | |
return ( | |
<Link to={url} {...rest}> | |
{children} | |
</Link> | |
); | |
} | |
export default useLinkComponent; | |
// In index | |
<AppProvider linkComponent={useLinkComponent}> | |
<App /> | |
</AppProvider> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment