리액트를 다루는 기술 보는 중인 데,

// ComponentA.tsx

function ComponentA() {

const boxRef = useRef<HTMLDivElement>(null);


const scrollToBottom = () => {

// boxRef 이용 해서 대충 스크롤 맨밑으로 이동하는 코드

}


// 대충 부모 div 보다 자식 div가 커서 스크롤 생긴 컴포넌트

return (

<div ref={boxRef}>

<div></div>

</div>

)

}

// App.tsx

function App() {

return (

<div>

<ComponentA></ComponentA>

<button onClick={/*여기에 scrollToBottom을 넣는 방법*/}>맨 밑으로</button>

</div>

)

}


App > button > onClick 주석 부분 방법 어캐함?


책에는 그냥 클래스로 되어 있어서 그냥 메서드로 가져오는 것 같던데


함수에서는 어캐 함수 안에 있는 걸 export시킴? ㅇㅅㅇ


useRef는 컴포넌트 함수 밖에 못 넣더라 ㅇㅅㅇ