I am building a reactjs app which has a few components in it (a navbar, a hero section,a form, and footer) i want that when clicked on a button in navbar it scrolls down to form i.e another component, I tried using react-router but it only renders that form and need it to scroll down to form keeping other components in place. How can i achieve this? basically this but in react
Asked
Active
Viewed 28 times
1 Answers
0
I think you may be able to achieve this by using vanilla Javascript like this:
<button
onclick="document.getElementById('idOfForm').scrollIntoView()">
</button>

Casey Knight
- 81
- 4
-
I tried out this but react does not allow to directly access Dom elements :( – PHAGUN JAIN Oct 15 '21 at 15:55