Skip to content

Commit 82c70a7

Browse files
committed
bug?added
1 parent 307cd9e commit 82c70a7

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/App.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ import Tools from './components/Tools';
88

99
class App extends Component {
1010

11+
clearBoard = () => {
12+
console.log("Clear Board");
13+
const context = document.getElementById('canvas').getContext('2d');
14+
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
15+
paint = false;
16+
clickX = [];
17+
clickY = [];
18+
clickDrag = [];
19+
20+
}
21+
1122
render() {
1223
return (
1324
<div>
@@ -21,7 +32,7 @@ class App extends Component {
2132
<Container>
2233
<Row>
2334
<Col className="justify-content-center">
24-
<Tools />
35+
<Tools clearBoard={this.clearBoard} />
2536
</Col>
2637
</Row>
2738
</Container>

src/components/Tools.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import {Button} from 'react-bootstrap'
33

4-
function Tools() {
4+
function Tools(props) {
55
return (
66
<div className="text-center">
77
<Button variant="success btn-sm" data-target="tooltip" title="Save Paint">Save</Button> {' '}
@@ -21,7 +21,7 @@ function Tools() {
2121
<ion-icon name="logo-facebook"></ion-icon>
2222
</Button> {' '}
2323

24-
<Button variant="danger btn-sm" data-target="tooltip" title="Clear the Paint board">Clear</Button>
24+
<Button variant="danger btn-sm" data-target="tooltip" onClick={props.clearBoard} title="Clear the Paint board">Clear</Button>
2525
</div>
2626
)
2727
}

0 commit comments

Comments
 (0)