Updated some things in the frontend

- App zeigt nun eine Zeit an, wenn backend zur verfügung steht
- Docker-Port ist auf 3000, weil Standard
This commit is contained in:
cami 2021-05-07 04:00:13 +02:00
parent 8fd0e44422
commit 18e6420500
2 changed files with 20 additions and 8 deletions

View file

@ -10,6 +10,6 @@ services:
- '.:/app:z' - '.:/app:z'
- '/app/node_modules' - '/app/node_modules'
ports: ports:
- 3001:3000 - 3000:3000
environment: environment:
- CHOKIDAR_USEPOLLING=true - CHOKIDAR_USEPOLLING=true

View file

@ -1,11 +1,23 @@
import React from 'react'; import React, { useState, useEffect } from 'react';
import HelloWorld from './HelloWorld'; import logo from './logo.svg';
import './App.css'; import './App.css';
function App() { function App() {
const [currentTime, setCurrentTime] = useState(0);
useEffect(() => {
fetch('/time').then(res => res.json()).then(data => {
setCurrentTime(data.time);
});
}, []);
return ( return (
<div classname="App"> <div className="App">
<HelloWorld /> <header className="App-header">
<p>The current time is {currentTime}.</p>
</header>
</div> </div>
); );
} }