mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-08 14:30:41 +02:00
frontend: removes unused stateRef
This commit is contained in:
parent
eb2da1c5dc
commit
393bde3280
@ -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 { Navbar, Form, Offcanvas, Container } from 'react-bootstrap';
|
||||||
import { hostname, port, socket } from './socket';
|
import { hostname, port, socket } from './socket';
|
||||||
import {
|
import {
|
||||||
@ -42,18 +42,12 @@ const reducer = (state: State, action: Action): State => {
|
|||||||
};
|
};
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [state, dispatch] = useReducer(reducer, null);
|
const [state, dispatch] = useReducer(reducer, null);
|
||||||
const stateRef = useRef(state); // Declare a reference to hold the current state
|
|
||||||
const [isInstantUpdate, setIsInstantUpdate] = useState(false);
|
const [isInstantUpdate, setIsInstantUpdate] = useState(false);
|
||||||
const [showSettings, setShowSettings] = useState(false);
|
const [showSettings, setShowSettings] = useState(false);
|
||||||
const [showNotification, setShowNotification] = useState(false);
|
const [showNotification, setShowNotification] = useState(false);
|
||||||
const [notifications, setNotifications] = useState<Notification[]>([]);
|
const [notifications, setNotifications] = useState<Notification[]>([]);
|
||||||
const [connectionStatus, setConnectionStatus] = useState('connecting');
|
const [connectionStatus, setConnectionStatus] = useState('connecting');
|
||||||
|
|
||||||
// Keep the state reference up to date
|
|
||||||
useEffect(() => {
|
|
||||||
stateRef.current = state;
|
|
||||||
}, [state]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Allow the user to add a custom css file
|
// Allow the user to add a custom css file
|
||||||
fetch(`http://${hostname}:${port}/custom.css`)
|
fetch(`http://${hostname}:${port}/custom.css`)
|
||||||
@ -74,6 +68,10 @@ const App = () => {
|
|||||||
fetch(`http://${hostname}:${port}/service-properties`)
|
fetch(`http://${hostname}:${port}/service-properties`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data: State) => dispatch({ type: 'SET_DATA', data }));
|
.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');
|
setConnectionStatus('connected');
|
||||||
});
|
});
|
||||||
socket.on('disconnect', () => {
|
socket.on('disconnect', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user