简体   繁体   中英

Navigate to a specific component (React)

I have a page 1 and a page 2 . On page 1 is a specific component. On page 2 I have a button. After clicking on that button I want to navigate to the position of the specific component on page 1 .

Is there a legit way to handle this?

By the way I am using GatsbyJS.

If you are using Gatsby, there is a plugin made for that :) https://www.gatsbyjs.org/packages/gatsby-plugin-anchor-links/

Else you can just set an id on the component on page 2 and link with /page2#yourid

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM