Skip to content

Can you get a ref for the <Canvas /> with TypeScript? #1017

Answered by joshuaellis
fnick851 asked this question in Q&A
Discussion options

You must be logged in to vote

Are you referring to the dom <canvas> element or it's container? the <canvas> dom element can be accessed using the useThree hook:

const { gl } = useThree()

React.useEffect(() => {
  console.log(gl.domElement) // will show me the `<canvas>` dom element.
}, [])

Replies: 2 comments 1 reply

Comment options

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

Answer selected by fnick851
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants