Skip to content

Commit 105bd3a

Browse files
committed
Add instructions to readme
1 parent 81c1d20 commit 105bd3a

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
@@ -1 +1,22 @@
11
# React Router Hash Link
2+
3+
***Note that this is for React Router v4, for v2/3 see [this solution](https://github.com/rafrex/react-router-hash-link/tree/react-router-v2/3).***
4+
5+
[Live Example](http://react-router-hash-link.rafrex.com/)
6+
7+
This is a solution to React Router's issue of not scrolling to `#hash-fragments` when using the `<Link>` component to navigate.
8+
9+
When you click on a link created with `react-router-hash-link` is will scroll to the element on the page with with the `id` that matches the `#hash-fragment` in the link. Note that you must use React Router's `BrowserRouter` for this to work.
10+
11+
```shell
12+
$ npm install --save react-router-hash-link
13+
```
14+
15+
```javascript
16+
// In YourComponent.js
17+
...
18+
import { HashLink as Link } from 'react-router-hash-link';
19+
...
20+
// Use it just like a RRv4 link:
21+
<Link to="/some/path#with-hash-fragment">Link to Hash Fragment<Link>
22+
```

0 commit comments

Comments
 (0)