aboutsummaryrefslogtreecommitdiffstats
path: root/src/App.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/App.js')
-rw-r--r--src/App.js35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/App.js b/src/App.js
index 3784575..a650d85 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,25 +1,28 @@
-import logo from './logo.svg';
-import './App.css';
+import React from 'react';
+import main from './services/main';
function App() {
+ const [count, setCount] = React.useState(0);
+ React.useEffect(() => {
+ async function fetchCount() {
+ const newCount = (await main.get()).data.count;
+ setCount(newCount);
+ }
+ fetchCount();
+ }, [setCount]);
return (
- <div className="App">
- <header className="App-header">
- <img src={logo} className="App-logo" alt="logo" />
- <p>
- Edit <code>src/App.js</code> and save to reload.
- </p>
- <a
- className="App-link"
- href="https://reactjs.org"
- target="_blank"
- rel="noopener noreferrer"
+ <div className='App'>
+ <header className='App-header'>
+ <h4>{count}</h4>
+ <button
+ onClick={async () => {
+ setCount((await main.increment()).data.count);
+ }}
>
- Learn React
- </a>
+ Increment
+ </button>
</header>
</div>
);
}
-
export default App;