Skip to content

Commit fc52647

Browse files
committed
Merge branch 'master' of github.com:rafrex/react-router-hash-link
2 parents 95f28ea + edfcbc0 commit fc52647

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,24 @@ import { HashLink as Link } from 'react-router-hash-link';
5959
scroll={el => el.scrollIntoView({ behavior: 'instant', block: 'end' })}
6060
>Link to Hash Fragment</Link>
6161
```
62+
63+
### Custom `Link`
64+
65+
The exported components are wrapped versions of the `Link` and `NavLink` exports of react-router-dom. In some cases you may need to provide a custom `Link` implementation.
66+
67+
For example, the gatsby static site generator requires you to use its implementation of `Link`. You can wrap it with the `genericHashLink` function of this package.
68+
69+
```jsx
70+
import { genericHashLink } from 'react-router-hash-link';
71+
import GatsbyLink from 'gatsby-link';
72+
73+
const MyHashLink = (props) => genericHashLink(props, GatsbyLink);
74+
75+
const MyComponent = () => (
76+
<div>
77+
The default wont work for you?
78+
<MyHashLink to="/faq#how-to-use-custom-link">No problem!</MyHashLink>
79+
</div>
80+
);
81+
```
82+

0 commit comments

Comments
 (0)