Skip to content

Instantly share code, notes, and snippets.

@ffdead
Last active November 4, 2021 13:41
Show Gist options
  • Save ffdead/0b701f8d81d44ecbf77f35600f5e6d5f to your computer and use it in GitHub Desktop.
Save ffdead/0b701f8d81d44ecbf77f35600f5e6d5f to your computer and use it in GitHub Desktop.
useCanvas hook in React component
const Image = () => {
const ref = useRef()
// add webgl component to global canvas while mounted
useCanvas(<WebGlImage image={ref} />)
return <img ref={ref} src={...} />
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment