Last active
November 4, 2021 13:41
-
-
Save ffdead/0b701f8d81d44ecbf77f35600f5e6d5f to your computer and use it in GitHub Desktop.
useCanvas hook in React component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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