天道酬勤,学无止境

react-scroll

react-scroll | How to scroll to a specific targeted component when clicking on Navbar Link

I am making a single scroller page using React and want to navigate to a specific section of the page. In HTML we use an href and anchor tag to achieve this interaction. I found a React library called react-scroll but I do not know how to link each component in different folders from the a link in the NavBar component. My NavBar has multiple links for scrolling to a section/ component. Any help would really be appreciated! import React, { Component } from "react"; import { Link, animateScroll as scroll } from "react-scroll"; class Navbar extends Component { render() { return ( <nav className=

2021-04-28 09:54:42    分类:问答    reactjs   scroll   react-router-dom   anchor-scroll   react-scroll