|
@@ -16,24 +16,26 @@ const CustomParamValue: React.FC<Props> = ({
|
|
|
name,
|
|
|
defaultValue,
|
|
|
}) => {
|
|
|
-
|
|
|
const { register, unregister, errors, watch, setValue } = useFormContext();
|
|
|
- const selectInputName: string = `${index}[name]`;
|
|
|
- const valInputName: string = `${index}[value]`;
|
|
|
+ const selectInputName = `${index}[name]`;
|
|
|
+ const valInputName = `${index}[value]`;
|
|
|
const selectedParamName = watch(selectInputName, name);
|
|
|
|
|
|
- React.useEffect(
|
|
|
- () => {
|
|
|
- if (selectedParamName) {
|
|
|
- setValue(valInputName, CUSTOM_PARAMS_OPTIONS[selectedParamName].defaultValue, true);
|
|
|
- }
|
|
|
- },
|
|
|
- [selectedParamName],
|
|
|
- );
|
|
|
+ React.useEffect(() => {
|
|
|
+ if (selectedParamName) {
|
|
|
+ setValue(
|
|
|
+ valInputName,
|
|
|
+ CUSTOM_PARAMS_OPTIONS[selectedParamName].defaultValue,
|
|
|
+ true
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }, [selectedParamName]);
|
|
|
|
|
|
- React.useEffect(
|
|
|
- () => { if (isFirstParam(index)) { unregister(valInputName) } },
|
|
|
- );
|
|
|
+ React.useEffect(() => {
|
|
|
+ if (isFirstParam(index)) {
|
|
|
+ unregister(valInputName);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
return (
|
|
|
<>
|
|
@@ -50,7 +52,7 @@ const CustomParamValue: React.FC<Props> = ({
|
|
|
disabled={isDisabled}
|
|
|
/>
|
|
|
<p className="help is-danger">
|
|
|
- <ErrorMessage errors={errors} name={valInputName}/>
|
|
|
+ <ErrorMessage errors={errors} name={valInputName} />
|
|
|
</p>
|
|
|
</>
|
|
|
);
|