[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 [isLoading, setIsLoading] = useState(true);
useEffect(() => {
if (monitorId !== undefined) {
const fetchMonitor = async () => {
try {
setIsLoading(true);
@@ -217,6 +218,9 @@ const useFetchMonitorById = ({ monitorId, setMonitor, updateTrigger }) => {
}
};
fetchMonitor();
} else {
setIsLoading(false);
}
}, [monitorId, setMonitor, updateTrigger]);
return [isLoading];
};