Scrollspy component
$ npm i react-scrollspy
var Scrollspy = require('react-scrollspy').Scrollspy;
...
<div>
<div>
<section id="section-1">section 1</section>
<section id="section-2">section 2</section>
<section id="section-3">section 3</section>
</div>
<Scrollspy items={ ['section-1', 'section-2', 'section-3'] } currentClassName="is-current">
<li><a href="#section-1">section 1</a></li>
<li><a href="#section-2">section 2</a></li>
<li><a href="#section-3">section 3</a></li>
</Scrollspy>
</div>
Id list of target contents.
Class name that apply to the navigation element paired with the content element in viewport.
Class name that apply to the navigation elements that have been scrolled past [optional].
HTML tag for Scrollspy component if you want to use other than ul
[optional].
Style attribute to be passed to the generated <ul/> element [optional].
Offset value that adjusts to determine the elements are in the viewport.
$ git clone https://github.com/makotot/react-scrollspy.git
$ cd react-scrollspy
$ npm i
$ npm run start
Pull requests and reporting an issue are always welcome :)
MIT