Created
June 7, 2020 04:42
-
-
Save TangerineCat/1d41a1fba0f63c472c087bf317fd6646 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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