-
-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The form.setFields
is causing the warning: "Warning: There may be circular references"
#649
Comments
import Form, { Field } from "rc-field-form";
const Input = ({ value = "", ...props }) => <input {...props} value={value} />;
function App() {
const [form] = Form.useForm<{ username: string }>();
const setFormFields = () => {
// Warning: Warning: There may be circular references
// https://github.com/react-component/util/blob/871c2c146b1050e33091005b32b8debcdcd15ca7/src/isEqual.ts#L14
form.setFields([{ name: "username", errors: [] }]);
};
return (
<Form form={form}>
<Field
name="username"
rules={[{ required: true }]}
onMetaChange={() => {}}
>
<Input />
</Field>
<button onClick={setFormFields}>Set Form Fields</button>
</Form>
);
}
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
form.setFields
會導致警告「Warning: There may be circular references」How to reproduce 如何重現
Possible causes 可能造成的原因
Both
errors
andwarnings
point toEMPTY_ERRORS
, causingisEqual
to perform adeepEqual
comparison, determining thatwarnings
and theerrors
already existing inrefSet
have the same reference.errors
與warnings
皆指向EMPTY_ERRORS
,造成 isEqual 進行deepEqual
時,判斷warnings
與已存在於refSet
的errors
有相同的 reference(参考)。field-form/src/Field.tsx
Lines 148 to 149 in 294125e
field-form/src/Field.tsx
Lines 517 to 518 in 294125e
field-form/src/Field.tsx
Lines 240 to 242 in 294125e
Related Pull Request 相關的 PR
#604
The text was updated successfully, but these errors were encountered: