when i click on one of the Links in the mobile view, it renders a new component for the product details page.
However the rendered view always starts at the bottom ..
how can i change this to always display the new component from the top ??
when i click on one of the Links in the mobile view, it renders a new component for the product details page.
However the rendered view always starts at the bottom ..
how can i change this to always display the new component from the top ??
You can try this :
componentDidMount() {
window.scrollTo(0, 0)
}
for stateless component with the help of hooks you can achieve this by doing:
useEffect(() => {
window.scrollTo(0,0);
}, [])