[PageSpeed]: Implement conditional check for monitorId inside useFetchMonitorById hook
This commit is contained in:
1 parent
eaa85bb9c4
commit
840069b935
1 file changed
+4
@@ -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];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user