Skip to content

Instantly share code, notes, and snippets.

@Ifmr24
Created July 25, 2019 02:09
Show Gist options
  • Save Ifmr24/d102ceddd2864cdfb886dea5e9855ca3 to your computer and use it in GitHub Desktop.
Save Ifmr24/d102ceddd2864cdfb886dea5e9855ca3 to your computer and use it in GitHub Desktop.
useLinkComponent.tsx
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