react-paint
react-paint copied to clipboard
How i can save image
Hi author. Thanks so much for your sharing. I have a question: How i can save image or push image to an api or read image content. Thanks you.
Try this:
in father component, add a ref
<ReactPaint {...props} ref="paint" />
presume the father component have a button to saveImage:
<button onClick={this.saveImage}>Upload</button>
and the handler function
saveImage(){
const dataUrl = this.refs.paint.canvas.toDataURL('image/png') // or .toBlob(callback)
// then post the dataUrl
}