Explorar el Código

Confirm reset

master
Dylan Baker hace 5 años
padre
commit
bd1ee7fe9e
Se han modificado 1 ficheros con 7 adiciones y 5 borrados
  1. 7
    5
      src/Board.tsx

+ 7
- 5
src/Board.tsx Ver fichero

49
   };
49
   };
50
 
50
 
51
   reset = () => {
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
   toggleCell = (x: number, y: number) => {
61
   toggleCell = (x: number, y: number) => {

Loading…
Cancelar
Guardar