Using anchor tags in react-router 4

To scroll down to your anchor tags, you need to install React Router Hash Link, with:

npm install --save react-router-hash-link

then import Hash Link:

import { HashLink as Link } from 'react-router-hash-link';

and then use Hash Link, for example:

<Link to="/pathLink#yourAnchorTag">Your link text</Link>

and at the destination component, for example:

<div id= "yourAnchorTag">
      <p>Linked to here<p>
</div>

Leave a Comment