File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
resources/scripts/components/dashboard Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 1- import React , { useEffect , useState } from 'react' ;
1+ import React , { useEffect , useRef , useState } from 'react' ;
22import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
33import { faServer } from '@fortawesome/free-solid-svg-icons/faServer' ;
44import { faEthernet } from '@fortawesome/free-solid-svg-icons/faEthernet' ;
@@ -21,18 +21,19 @@ const isAlarmState = (current: number, limit: number): boolean => {
2121} ;
2222
2323export default ( { server, className } : { server : Server ; className : string | undefined } ) => {
24+ const interval = useRef < number > ( null ) ;
2425 const [ stats , setStats ] = useState < ServerStats | null > ( null ) ;
2526
2627 const getStats = ( ) => getServerResourceUsage ( server . uuid ) . then ( data => setStats ( data ) ) ;
2728
2829 useEffect ( ( ) => {
29- let interval : any = null ;
3030 getStats ( ) . then ( ( ) => {
31- interval = setInterval ( ( ) => getStats ( ) , 20000 ) ;
31+ // @ts -ignore
32+ interval . current = setInterval ( ( ) => getStats ( ) , 20000 ) ;
3233 } ) ;
3334
3435 return ( ) => {
35- interval && clearInterval ( interval ) ;
36+ interval . current && clearInterval ( interval . current ) ;
3637 } ;
3738 } , [ ] ) ;
3839
You can’t perform that action at this time.
0 commit comments