#useHistory with useNavigate

1 messages · Page 1 of 1 (latest)

candid glacier
#

in the 6v version u cannot use useHistory anymore and i try to use useNavigate but cant do the same thing.
i have container with 4 components that are on the top of each other and i want that when i click on a button it wont just show me 1 component but will go down to the third component.
i tried to find a solution and couldn't please help :*)

placid merlin
#

Are you trying to scroll to the third component?

candid glacier
#

yes

placid merlin
#

If so, you could add an id to your component, and use an anchor tag which refers to that id. Clicking on the anchor would made you jump to that component

#

<MyComp id="target-me" /> then the anchor which targets it would be the following: <a href='#target-me'>Jump to MyComp</>

candid glacier
#

i will check it thank you 🙂

placid merlin
#

good luck 🙂

candid glacier
#

it works but when im on another container it wont go to this container and anchor it

placid merlin
#

Would you be able to share a code example with us?

#

Do you have some custom components which you assign an id to?
If so, make sure you pass down the id property and use it inside that component.