Reactjs'de id ile link verme
Arkadaslar reactjs'de ayni sayfada bir component gitmesini istiyorum html'de mesela bir div'e id vererek a element kullanabilirdin
<div id="hello">
<h4>Hello World</h4>
</div>
<a href="#hello" target="_blank">Labela</a>
iste bu ornek reactjs'de react-router kullaniyorum nasil yapabilirim
tesekkurler
Soru hatalı mı? 👎
Eğer sorunun kurallara aykırı olduğunu düşünüyorsanız lütfen bize bildirin!
Cevaplar (1)
Aradığın cevap bu diye düşünüyorum
const ScrollDemo = () => {
const myRef = useRef(null)
const executeScroll = () => myRef.current.scrollIntoView()
// run this function from an event handler or an effect to execute scroll
return (
<>
<div ref={myRef}>Element to scroll to</div>
<button onClick={executeScroll}> Click to scroll </button>
</>
)
}