Answer the question
In order to leave comments, you need to log in
How to make simple scroll (no animation) to anchor without changing address bar (no jQuery on React)?
There is an element with id="testElement". There is a link
Everything works ok, smoothness and animation are not needed, but now you need to learn how, for example, using js, scroll to the desired element without adding #testElement to the address bar (smoothness and animation are still not needed)
React project. We need the simplest possible idea. <a href="#testElement">Прокрути</a>
Answer the question
In order to leave comments, you need to log in
It couldn't be easier:
Demo
In the React implementation something like this:
handleLinkClick = e => {
e.preventDefault();
const element = document.getElementById(e.target.href);
element.scrollIntoView();
};
I think one of these will definitely help
https://stackoverflow.com/questions/43441856/react...
https://codedaily.io/tutorials/8/Build-a-Reusable-...
https://codepen. io/takatama/pen/mVvbqx
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question