aboutsummaryrefslogtreecommitdiffstats
path: root/src/App.js
blob: a650d852bcb20853f5b88032bcfe3858a7b39fcc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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'>
        <h4>{count}</h4>
        <button
          onClick={async () => {
            setCount((await main.increment()).data.count);
          }}
        >
          Increment
        </button>
      </header>
    </div>
  );
}
export default App;