From 393bde3280038da1390dfbb6fef3d0080cef2676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Wed, 20 Dec 2023 16:57:20 +0100 Subject: [PATCH] frontend: removes unused stateRef --- frontend/src/App.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1a0d42e..675817a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useReducer, useRef, useState } from 'react'; +import { useCallback, useEffect, useReducer, useState } from 'react'; import { Navbar, Form, Offcanvas, Container } from 'react-bootstrap'; import { hostname, port, socket } from './socket'; import { @@ -42,18 +42,12 @@ const reducer = (state: State, action: Action): State => { }; const App = () => { const [state, dispatch] = useReducer(reducer, null); - const stateRef = useRef(state); // Declare a reference to hold the current state const [isInstantUpdate, setIsInstantUpdate] = useState(false); const [showSettings, setShowSettings] = useState(false); const [showNotification, setShowNotification] = useState(false); const [notifications, setNotifications] = useState([]); const [connectionStatus, setConnectionStatus] = useState('connecting'); - // Keep the state reference up to date - useEffect(() => { - stateRef.current = state; - }, [state]); - useEffect(() => { // Allow the user to add a custom css file fetch(`http://${hostname}:${port}/custom.css`) @@ -74,6 +68,10 @@ const App = () => { fetch(`http://${hostname}:${port}/service-properties`) .then((response) => response.json()) .then((data: State) => dispatch({ type: 'SET_DATA', data })); + fetch(`http://${hostname}:${port}/web-settings`).then((response) => + response.json() + ); + // .then((data: State) => dispatch({ type: 'SET_DATA', data })); setConnectionStatus('connected'); }); socket.on('disconnect', () => {