Skip to content

Instantly share code, notes, and snippets.

@codewithbernard
Created November 29, 2021 11:42
Show Gist options
  • Select an option

  • Save codewithbernard/2022cb8a310669aeb3a8ae41d3ca58b9 to your computer and use it in GitHub Desktop.

Select an option

Save codewithbernard/2022cb8a310669aeb3a8ae41d3ca58b9 to your computer and use it in GitHub Desktop.
import React from "react";
import { Link } from "react-router-dom";
import { HashScroll } from "react-hash-scroll";
const HashScrollPage = () => {
return (
<main className="page">
<nav>
<ul>
<li>
<Link to="/hash-scroll#hash-section-1">Go To Section 1</Link>
</li>
<li>
<Link to="/hash-scroll#hash-section-2">Go To Section 2</Link>
</li>
<li>
<Link to="/hash-scroll#hash-section-3">Go To Section 3</Link>
</li>
</ul>
</nav>
<article>
<HashScroll hash="#hash-section-1">
<section>Section 1</section>
</HashScroll>
<HashScroll hash="#hash-section-2">
<section>Section 2</section>
</HashScroll>
<HashScroll hash="#hash-section-3">
<section>Section 3</section>
</HashScroll>
</article>
</main>
);
};
export default HashScrollPage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment