removed conditional calling of hook and added early return in useHardwareMonitorsFetch
This commit is contained in:
1 parent
8df78089e6
commit
5c74c0e452
2 files changed
+6
-1
No files matched your search
@@ -61,7 +61,7 @@ const CreateInfrastructureMonitor = () => {
|
||||
const isCreate = typeof monitorId === "undefined";
|
||||
|
||||
// Fetch monitor details if editing
|
||||
const { monitor, isLoading, networkError } = isCreate ? {} : useHardwareMonitorsFetch({ monitorId });
|
||||
const { monitor, isLoading, networkError } = useHardwareMonitorsFetch({ monitorId });
|
||||
|
||||
// State
|
||||
const [errors, setErrors] = useState({});
|
||||
|
||||
@@ -2,6 +2,11 @@ import { useEffect, useState } from "react";
|
||||
import { networkService } from "../../../../main";
|
||||
|
||||
const useHardwareMonitorsFetch = ({ monitorId, dateRange }) => {
|
||||
|
||||
// Abort early if creating monitor
|
||||
if (!monitorId) {
|
||||
return { monitor: null, isLoading: false, networkError: null };
|
||||
}
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [networkError, setNetworkError] = useState(false);
|
||||
const [monitor, setMonitor] = useState(undefined);
|
||||
|
||||
Reference in new issue
Block a user