[PageSpeed]: Use typeof operator for clarity, and to handle undeclared and undefined variables

This commit is contained in:
Jesulayomy committed 2025-07-11 13:40:29 -04:00
1 parent f04fd8bea2
commit 352d3a1647
1 file changed
+4 -4
+4 -4
View File
@@ -205,7 +205,10 @@ const useFetchStatsByMonitorId = ({
const useFetchMonitorById = ({ monitorId, setMonitor, updateTrigger }) => {
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
if (monitorId !== undefined) {
if (typeof monitorId === "undefined") {
setIsLoading(false);
return
};
const fetchMonitor = async () => {
try {
setIsLoading(true);
@@ -218,9 +221,6 @@ const useFetchMonitorById = ({ monitorId, setMonitor, updateTrigger }) => {
}
};
fetchMonitor();
} else {
setIsLoading(false);
}
}, [monitorId, setMonitor, updateTrigger]);
return [isLoading];
};