File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/react-radfish/Application Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 11import { Toast } from "../alerts" ;
2- import { createContext , useEffect , useContext } from "react" ;
2+ import { createContext , useEffect , useContext , useRef } from "react" ;
33import { useOfflineStatus , useToasts , dispatchToast } from "../hooks" ;
44
55const ApplicationContext = createContext ( ) ;
66
77function ApplicationComponent ( props ) {
88 const { toasts } = useToasts ( ) ;
99 const { isOffline } = useOfflineStatus ( ) ;
10+ const prevIsOffline = useRef ( null ) ;
1011
1112 useEffect ( ( ) => {
12- if ( ! isOffline ) {
13+ if ( prevIsOffline . current === null ) {
14+ prevIsOffline . current = isOffline ;
15+ } else if ( prevIsOffline . current && ! isOffline ) {
1316 dispatchToast ( { message : "Application is online" , status : "info" , duration : 3000 } ) ;
1417 }
18+ prevIsOffline . current = isOffline ;
1519 } , [ isOffline ] ) ;
1620
1721 return (
You can’t perform that action at this time.
0 commit comments