Browse Source

Confirm reset

master
Dylan Baker 3 years ago
parent
commit
bd1ee7fe9e
1 changed files with 7 additions and 5 deletions
  1. 7
    5
      src/Board.tsx

+ 7
- 5
src/Board.tsx View File

@@ -49,11 +49,13 @@ class Board extends React.Component<{}, State> {
49 49
   };
50 50
 
51 51
   reset = () => {
52
-    this.setState({ grid: [...INITIAL_GRID] });
53
-    this.stop();
54
-    this.setState({ running: false });
55
-    this.setState({ cellSize: DEFAULT_CELL_SIZE });
56
-    this.setState({ width: DEFAULT_WIDTH, height: DEFAULT_HEIGHT });
52
+    if (window.confirm('Are you sure?')) {
53
+      this.setState({ grid: [...INITIAL_GRID] });
54
+      this.stop();
55
+      this.setState({ running: false });
56
+      this.setState({ cellSize: DEFAULT_CELL_SIZE });
57
+      this.setState({ width: DEFAULT_WIDTH, height: DEFAULT_HEIGHT });
58
+    }
57 59
   };
58 60
 
59 61
   toggleCell = (x: number, y: number) => {

Loading…
Cancel
Save