can not set state in render (#483)
This commit is contained in:
parent
74aee6090d
commit
6102770fbf
1 changed files with 6 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { ArrayField, UseFormMethods } from "react-hook-form";
|
import { ArrayField, UseFormMethods } from "react-hook-form";
|
||||||
import { ActionGroup, Button, TextInput } from "@patternfly/react-core";
|
import { ActionGroup, Button, TextInput } from "@patternfly/react-core";
|
||||||
|
@ -68,9 +68,11 @@ export const AttributesForm = ({
|
||||||
|
|
||||||
const watchLast = watch(`attributes[${fields.length - 1}].key`, "");
|
const watchLast = watch(`attributes[${fields.length - 1}].key`, "");
|
||||||
|
|
||||||
if (fields.length === 0) {
|
useEffect(() => {
|
||||||
append({ key: "", value: "" });
|
if (fields.length === 0) {
|
||||||
}
|
append({ key: "", value: "" });
|
||||||
|
}
|
||||||
|
}, [fields]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
Loading…
Reference in a new issue