Base64Png Editor Disabled Update Canvas
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
useEffect(() => { | |
const ctx = canvasRef.current?.getContext("2d")!; | |
canvasRef.current!.width = 0; | |
canvasRef.current!.height = 0; | |
imageRef.current!.onload = () => { | |
canvasRef.current!.width = imageRef.current!.width; | |
canvasRef.current!.height = imageRef.current!.height; | |
ctx.drawImage(imageRef.current!, 0, 0); | |
setEditorContent(canvasRef.current!.toDataURL().split(",")[1]); | |
/** | |
* When the image finishes to load, the tweakers can properly work | |
*/ | |
setDisabled(false); | |
}; | |
return () => { | |
imageRef.current!.onload = null; | |
}; | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment