[PageSpeed]: Implement conditional check for monitorId inside useFetchMonitorById hook

This commit is contained in:
Jesulayomy committed 2025-07-10 21:53:33 -04:00
1 parent eaa85bb9c4
commit 840069b935
1 file changed
+4
+4
View File
@@ -205,6 +205,7 @@ const useFetchStatsByMonitorId = ({
const useFetchMonitorById = ({ monitorId, setMonitor, updateTrigger }) => { const useFetchMonitorById = ({ monitorId, setMonitor, updateTrigger }) => {
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
useEffect(() => { useEffect(() => {
if (monitorId !== undefined) {
const fetchMonitor = async () => { const fetchMonitor = async () => {
try { try {
setIsLoading(true); setIsLoading(true);
@@ -217,6 +218,9 @@ const useFetchMonitorById = ({ monitorId, setMonitor, updateTrigger }) => {
} }
}; };
fetchMonitor(); fetchMonitor();
} else {
setIsLoading(false);
}
}, [monitorId, setMonitor, updateTrigger]); }, [monitorId, setMonitor, updateTrigger]);
return [isLoading]; return [isLoading];
}; };