// You can do this:
function App() {
return (
<div onChange={() => console.log('You clicked me')}>
hello!
</div>
)
}
// or...
import {useRef, useEffect} from 'react'
const wrapperRef = useRef(null)
useEffect(() => {
function callback() {
console.log('You clicked me!')
}
wrapperRef.current?.addEventListener('click', callback)
return () => wrapperRef.current?.removeEventListener('click', callback)
}, [])
function App() {
return (
<div ref={wrapperRef}>
hello!
</div>
)
}