From 18e64205004a47c26bed10cdf35401e477686ba2 Mon Sep 17 00:00:00 2001 From: cami Date: Fri, 7 May 2021 04:00:13 +0200 Subject: [PATCH] Updated some things in the frontend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - App zeigt nun eine Zeit an, wenn backend zur verfügung steht - Docker-Port ist auf 3000, weil Standard --- frontend/docker-compose.yml | 2 +- frontend/src/App.js | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/frontend/docker-compose.yml b/frontend/docker-compose.yml index 0bcaa09..4b51888 100644 --- a/frontend/docker-compose.yml +++ b/frontend/docker-compose.yml @@ -10,6 +10,6 @@ services: - '.:/app:z' - '/app/node_modules' ports: - - 3001:3000 + - 3000:3000 environment: - CHOKIDAR_USEPOLLING=true diff --git a/frontend/src/App.js b/frontend/src/App.js index 0a34499..8ce106f 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -1,13 +1,25 @@ -import React from 'react'; -import HelloWorld from './HelloWorld'; +import React, { useState, useEffect } from 'react'; +import logo from './logo.svg'; import './App.css'; function App() { - return ( -
- -
- ); + const [currentTime, setCurrentTime] = useState(0); + + useEffect(() => { + fetch('/time').then(res => res.json()).then(data => { + setCurrentTime(data.time); + }); + }, []); + + return ( +
+
+ + +

The current time is {currentTime}.

+
+
+ ); } export default App;