form.getFieldValue method will create a new field in fieldMeta
form.getFieldValue method will create a new field in fieldMeta. This cause an issue when set an array value to the field later.
version 2.2.x
getFieldMeta(name) { this.fieldsMeta[name] = this.fieldsMeta[name] || {}; return this.fieldsMeta[name]; }
version 1.4.x
getValueFromFieldsInternal(name, fields) { const field = fields[name]; if (field && 'value' in field) { return field.value; } const fieldMeta = this.fieldsMeta[name]; return fieldMeta && fieldMeta.initialValue; }
https://codesandbox.io/s/50x3l7y59n
Steps to reproduce
- click "Add field" button
- new row will be created with no issue
- click "Error Button" button, no impacts to the function since the "list" variable has been initialized as an Array correctly.
- reload the page
- this time click "Error Button" first.
- a new field "list" will be added to fieldMeta
- click "Add field" button
- error occurred because list is an 'object' instead of 'Array'
This bug stumped me for two days. I definitely did not expect a method named "getFieldValue" to create a new field!!!