getFieldDecrator register strangely
See original GitHub issueVersion
3.1.6
Environment
macOS 10.11.6, Chrome 63.0.3239.132
Reproduction link
https://codesandbox.io/s/o7l8nxyyxy
Steps to reproduce
click add button more than one time
What is expected?
the data get by getFieldsValue
is always an array.
What is actually happening?
the data got is a object after the second click
There is a workaroud can avoid the problem, but it seems inelegant: getFieldsDecorator
a new key such as tempConditions
with a copy data.
Is it a bug of antd or is it a usage error ?
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Antd getFieldDecorator()'s options trigger not working
When I add the trigger: 'onBlur' the Input component doesn't show the text that i enter. The idea is for Antd to collect...
Read more >React ant design form validation not working (on submit)-Reactjs
I create a build of my react app and connected with electron. · I am trying to make an API request based on...
Read more >How to show error message when someone leave empty fields
If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are...
Read more >TypeScript repositories for a bounty hunter | by IssueHunt
IssueHunt is an issue-based bounty platform for open source projects. Since launched in July 2018, a lot of projects have been participating to...
Read more >Form E - OSCHINA - 中文开源技术交流社区
... { getFieldDecorator } = this.props.form; return ( <Form onSubmit={this. ... className="login-form-button"> Log in </Button> Or <a href="">register now!
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Dynamic Form Item example from https://ant.design/components/form/
What doesn’t make sense to me is, why do we need two different fields
getFieldDecorator('keys', { initialValue: [] });
=> keys andgetFieldDecorator('names[${k}]', {
=> names? When submitting the form the data is duplicated:Instinct tells me I should be able to do
getFieldDecorator('names', { initialValue: [] });
andgetFieldValue('names')
but then I get this error:What am I missing here?
This works perfectly for me though if the comparator is used the same warning pop up only at the start if the comparator is not used (which is used only to make id value to list size at initially ) no warning will be displayed. [Solution here
](https://codesandbox.io/s/duplicate-form-j7qso?file=/index.js:1585-3123) //Initial value of the keys in the list getFieldDecorator(“keys”, { initialValue: [0, 1, 2] });
//Initial values of the list const initialNames = [“A”, “B”, “C”];
// const keys = getFieldValue(“keys”);
// Array Comporator const arrayEquals = (a, b) => { return ( Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((val, index) => val === b[index]) ); };
// Comporator that will only true initially and set id value to arrays.length-1 if (getFieldValue(“keys”).length === initialNames.length) { if (!arrayEquals(getFieldValue(“names”), initialNames)) { id = getFieldValue(“keys”).length - 1; console.log(“id”, id); } }