Skip to content
Discussion options

You must be logged in to vote

With R3F v8 you're able to use react-dom's built-in synthetic events (onClick, etc.) among other props on the canvas, but I'd recommend using pointer events where you can. The following can be a re-usable component but you can target the canvas as well.

const container = useRef()

useEffect(() => {
  const onPointerUp = () => {}
  const onPointerDown = () => {}
  const onPointerMove = () => {}

  container.current.addEventListener('pointerup', onPointerUp)
  container.current.addEventListener('pointerdown', onPointerDown)
  container.current.addEventListener('pointermove', onPointerMove)

  return () => {
    container.current.removeEventListener('pointerup', onPointerUp)
    container.cu…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Iambizi
Comment options

Answer selected by Iambizi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants