A
A
Alex Krynytskyi2021-02-18 23:42:56
React
Alex Krynytskyi, 2021-02-18 23:42:56

How to scroll to an element after routing in ReactJS?

Found only solution without routing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex4answ, 2021-02-18
@alex4answ

As well as without routing, as in normal js, with routing, exactly the same mount of components occurs.
You can use refs and the like however you like.
1. yourDOMElement.scrollIntoView();
2.

window.scrollBy(yourDOMElement.getBoundingClientRect().top);

Simply put, exactly the same as without React.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question