Skip to content

Commit 714129f

Browse files
committed
fix: event dispatch in react-radfish unit tests
1 parent fe5b8cf commit 714129f

File tree

5 files changed

+310
-31
lines changed

5 files changed

+310
-31
lines changed

package-lock.json

Lines changed: 236 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-radfish/hooks/useOfflineStatus/useOfflineStatus.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ export const useOfflineStatus = () => {
1212
useEffect(() => {
1313
updateOnlineStatus();
1414

15-
application.addEventListener("online", updateOnlineStatus);
16-
application.addEventListener("offline", updateOnlineStatus);
15+
const setIsOfflineTrue = () => setIsOffline(true);
16+
const setIsOfflineFalse = () => setIsOffline(false);
17+
18+
application.addEventListener("online", setIsOfflineFalse);
19+
application.addEventListener("offline", setIsOfflineTrue);
1720

1821
return () => {
19-
application.removeEventListener("online", updateOnlineStatus);
20-
application.removeEventListener("offline", updateOnlineStatus);
22+
application.removeEventListener("online", setIsOfflineFalse);
23+
application.removeEventListener("offline", setIsOfflineTrue);
2124
};
2225
}, [application]);
2326

0 commit comments

Comments
 (0)