Pete
Pete

Reputation: 514

How can I prevent react-router Link to direct to the middle of a new view?

When I use a simple Link as in:

import {Link} from 'react-router-dom'

<Link
  className="btn btn-primary btn-lg"
  to={'/path'}>
  Learn More
</Link>

the new view opens up at the middle of the page instead of at the top. How can I change that? Thanks.

Upvotes: 0

Views: 1092

Answers (1)

Mark Rabey
Mark Rabey

Reputation: 1415

Take a look at Scroll Restoration from the React Router docs.

Upvotes: 3

Related Questions