Move enable save button logic to a use effect hook. This updates state without delay. (#2548)
This commit is contained in:
@@ -66,14 +66,16 @@ export const ConfigNotify = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setEnableSaveButton(canSave());
|
||||||
|
}, [formDataValues]);
|
||||||
|
|
||||||
// update individual values in state
|
// update individual values in state
|
||||||
const handleFieldChange = ({ fieldName, value }: UpdateArgs) => {
|
const handleFieldChange = ({ fieldName, value }: UpdateArgs) => {
|
||||||
setFormDataValues({
|
setFormDataValues({
|
||||||
...formDataValues,
|
...formDataValues,
|
||||||
[fieldName]: value,
|
[fieldName]: value,
|
||||||
});
|
});
|
||||||
|
|
||||||
setEnableSaveButton(canSave());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// toggle switch.
|
// toggle switch.
|
||||||
|
|||||||
Reference in New Issue
Block a user