Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TangerineCat/1d41a1fba0f63c472c087bf317fd6646 to your computer and use it in GitHub Desktop.
Save TangerineCat/1d41a1fba0f63c472c087bf317fd6646 to your computer and use it in GitHub Desktop.
function DrawingComponent(props: DrawingComponentProps) {
...
const [histories, setHistories] = useState<Array<History>>([]);
...
function clear() {
layerRef.current?.destroyChildren();
layerRef.current?.clear();
console.log(histories);
setHistories([...histories, { mode: "clear", startTime: Date.now() }]);
console.log(histories);
if (lastDrawMode === "brush") {
console.log("draw");
drawLine();
} else {
eraseLine();
}
}
...
render(
<Button variant="secondary" onClick={clear}>
Clear
</Button>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment