embiem / react-canvas-draw

React Component for drawing in canvas
https://embiem.github.io/react-canvas-draw/
MIT License
892 stars 315 forks source link

How I can use the CLEAR function? #72

Closed marcosaurelioo closed 4 years ago

marcosaurelioo commented 4 years ago

Well I tried these way: ``

``
Where the saveableCanvas come from?

bsteps commented 4 years ago
<div> 
<CanvasDraw 
   brushColor='#000' 
   lazyRadius='0' 
   brushRadius='3' 
   canvasWidth={400} 
   canvasHeight={200} 
   style={{ marginLeft: 10, marginRight: 10 }}
   ref={canvasDraw => (this.saveableCanvas= canvasDraw)}
>
</CanvasDraw>
<button onClick={() => this.saveableCanvas.clear()}>Clear</button> </div>
marcosaurelioo commented 4 years ago

@NishantTadvi Didn't work.

marcosaurelioo commented 4 years ago

Well, work with useRef().

parammittal16 commented 4 years ago

@Maark007 can you tell me how you user useRef here ? Thanks :)