embiem / react-canvas-draw

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

Update props without refreshing #110

Open thekidchad opened 3 years ago

thekidchad commented 3 years ago

Hi, Im looking for a solution to update props of react-canvas-draw realtime. I didnt find any solution to re-render the canvas.

For example : <CanvasDraw ref={(canvasDraw) => (this.saveableCanvas = canvasDraw)} brushColor={"#000"} brushRadius={1} hideGrid={() => this.setState({ hideGrid: true })} />

doesnt remove the grid in a realtime. May we need to rerender the canvasdraw ? How can we do it ?

Anybody has a solution ? Best regards

lfdom commented 3 years ago

Use the key prop from react,

key={`id-${showGrid}`}

that will force the component to re-render