Download calculator/src/component/App.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 598 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/calculator/src/component/App.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@f5071caa249115f3b590492f1c8eb471e02aae4b/calculator/src/component/App.js
-
curl -L -o App.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/f5071caa249115f3b590492f1c8eb471e02aae4b/calculator/src/component/App.js
598 Bytes
| import React from "react"; | |
| import Display from "./Display"; | |
| import ButtonPanel from "./ButtonPanel"; | |
| import calculate from "../logic/calculate"; | |
| import "./App.css"; | |
| export default class App extends React.Component { | |
| state = { | |
| total: null, | |
| next: null, | |
| operation: null, | |
| }; | |
| handleClick = buttonName => { | |
| this.setState(calculate(this.state, buttonName)); | |
| }; | |
| render() { | |
| return ( | |
| <div className="component-app"> | |
| <Display value={this.state.next || this.state.total || "0"} /> | |
| <ButtonPanel clickHandler={this.handleClick} /> | |
| </div> | |
| ); | |
| } | |
| } | |