I have a navigation bar with several links and I would like to be able to bring a visitor to the dedicated component smoothly when clicking on one of the navigation items. All the components are below the navigation bar as I scroll through the app. I know how it can be simply done with just HTML and CSS when a static website is built, but as I tried to do the same way in React, it obviously did not work. Is it possible to do with just React, not using any packages (React Router, react-scroll etc.)? If so, how can I do it?
For reference with just HTML and CSS: https://codesandbox.io/s/objective-ganguly-fzqnrz?file=/index.html
This is what I would like to be able to do, but with a smooth transition and without packages. Here is the code:
Navigation.js (the href's are just placeholders to illustrate the idea)
const Navigation = () => {
return (
<header>
<nav>
<ul>
<li>
<a href="#home">Home</a>
</li>
<li>
<a href="#projects">Projects</a>
</li>
<li>
<a href="#contact">Contact</a>
</li>
</ul>
</nav>
</header>
);
};
export default Navigation;
About.js
const About = () => {
return (
<div>
<div>
<p>
{/* Content here... */}
</p>
</div>
</div>
);
};
export default About;