fix: Update useState default values in exportModal and flowSettingsModal (#5698)
* fix: Update useState default values in exportModal and flowSettingsModal - Update the default values for the useState hooks in exportModal and flowSettingsModal to handle null values for currentFlow. - Use the nullish coalescing operator (??) to set empty strings as default values for name and description. - This ensures that the components do not throw errors when currentFlow is null or undefined. Refs: #5670, #5672 * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
a756061f0b
commit
1f63ebeaef
2 changed files with 12 additions and 10 deletions
|
|
@ -22,11 +22,13 @@ const ExportModal = forwardRef(
|
|||
const [checked, setChecked] = useState(false);
|
||||
const currentFlow = useFlowStore((state) => state.currentFlow);
|
||||
useEffect(() => {
|
||||
setName(currentFlow!.name);
|
||||
setDescription(currentFlow!.description);
|
||||
}, [currentFlow!.name, currentFlow!.description]);
|
||||
const [name, setName] = useState(currentFlow!.name);
|
||||
const [description, setDescription] = useState(currentFlow!.description);
|
||||
setName(currentFlow?.name ?? "");
|
||||
setDescription(currentFlow?.description ?? "");
|
||||
}, [currentFlow?.name, currentFlow?.description]);
|
||||
const [name, setName] = useState(currentFlow?.name ?? "");
|
||||
const [description, setDescription] = useState(
|
||||
currentFlow?.description ?? "",
|
||||
);
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ export default function FlowSettingsModal({
|
|||
const flows = useFlowsManagerStore((state) => state.flows);
|
||||
const flow = flowData ?? currentFlow;
|
||||
useEffect(() => {
|
||||
setName(flow!.name);
|
||||
setDescription(flow!.description);
|
||||
setName(flow?.name ?? "");
|
||||
setDescription(flow?.description ?? "");
|
||||
}, [flow?.name, flow?.description, open]);
|
||||
|
||||
const [name, setName] = useState(flow!.name);
|
||||
const [description, setDescription] = useState(flow!.description);
|
||||
const [endpoint_name, setEndpointName] = useState(flow!.endpoint_name ?? "");
|
||||
const [name, setName] = useState(flow?.name ?? "");
|
||||
const [description, setDescription] = useState(flow?.description ?? "");
|
||||
const [endpoint_name, setEndpointName] = useState(flow?.endpoint_name ?? "");
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
const [disableSave, setDisableSave] = useState(true);
|
||||
const autoSaving = useFlowsManagerStore((state) => state.autoSaving);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue