-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Currently, the SketchPad does not re-draw on undo, only after the user draws on the canvas. This can be slightly annoying, so it makes sense for the canvas to re-draw on undo.
Can be implemented as:
export const SketchPad: FC<SketchPadProps & DrawPathOptions> = (props) => {
// Initialization, setting state, etc.
const [undoListener, setUndoListener] = useState(0);
useEffect(() => {
draw()
}, [paths, draw, undoListener]);
const handleUndo = () => {
setPaths((currentPaths) => {
currentPaths.pop();
return currentPaths;
}
setUndoListener(undoListener + 1); // change state to trigger re-render
}
}Metadata
Metadata
Assignees
Labels
No labels