diff --git a/src/App.jsx b/src/App.jsx index a9b4f52..1e3ffe7 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,4 +1,4 @@ -import React, { Component } from "react"; +import React, { useState } from "react"; import "./App.css"; import { Button } from "./components/Button"; import { Button1 } from "./components/Button1"; @@ -8,61 +8,107 @@ import { Input } from "./components/Input"; import { ClearButton } from "./components/ClearButton"; import * as math from "mathjs"; -class App extends Component { - constructor(props) { - super(props); +// class App extends Component { +// constructor(props) { +// super(props); - this.state = { - input: "" - }; - } +// this.state = { +// input: "" +// }; +// } - addToInput = val => { - this.setState({ input: this.state.input + val }); - }; +// addToInput = val => { +// this.setState({ input: this.state.input + val }); +// }; - handleEqual = () => { - this.setState({ input: math.evaluate(this.state.input) }); - }; +// handleEqual = () => { +// this.setState({ input: math.evaluate(this.state.input) }); +// }; - render() { - return ( -
-
- -
- this.setState({ input: "" })}>AC - - - -
-
- - - - -
-
- - - - -
-
- - - - -
-
- 0 - . - this.handleEqual()}>= -
-
-
- ); - } +// render() { +// return ( +//
+//
+// +//
+// this.setState({ input: "" })}>AC +// +// +// +//
+//
+// +// +// +// +//
+//
+// +// +// +// +//
+//
+// +// +// +// +//
+//
+// 0 +// . +// this.handleEqual()}>= +//
+//
+//
+// ); +// } +// } + +function App() { + const [input, setInput] = useState(""); + + const addToInput = val => setInput(input + val); + const handleEqual = () => setInput(math.evaluate(input)); + + return ( +
+
+ +
+ setInput("")}> + AC + + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ 0 + . + = +
+
+
+ ); } export default App;