You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What you were expecting:
expected data to be displayed inside <ReferenceArrayInput> c < AutocompleteArrayInput / >
What happened instead:
The application crashes
Steps to reproduce:
went into debugging and found a file with an error http://localhost:3001/static/js/C:/_Projects/ASKUG/web-askug-service-portal/node_modules/ra-core/esm/form/useInitializeFormWithRecord.js
Related code:
import { useEffect } from 'react';
import { useForm } from 'react-final-form';
/**
* Restore the record values which should override any default values specified on the form.
*/
var useInitializeFormWithRecord = function (record) {
var form = useForm();
useEffect(function () {
if (!record) {
return;
}
var registeredFields = form.getRegisteredFields();
// react-final-form does not provide a way to set multiple values in one call.
// Using batch ensure we don't get rerenders until all our values are set
form.batch(function () {
Object.keys(record).forEach(function (key) {
// We have to check that the record key is actually registered as a field
// as some record keys may not have a matching input
if (registeredFields.some(function (field) { return field === key; })) {
if (Array.isArray(record[key])) {
// array of values
record[key].forEach(function (value, index) {
///ERROR HERE
for record = {
tagsIds: []
tagsIds: ["ck88peh0401av0771i43t3kw9", "ck7yrq9sk00kc07683mntfi5j"]
}
value = "ck88peh0401av0771i43t3kw9" - scalar value, not array of objects
(value && Object.keys(value).length > 0) ==> true!
if (value && Object.keys(value).length > 0) {
// array of objects
Object.keys(value).forEach(function (key2) {
form.change(key + "[" + index + "]." + key2, value[key2]);
});
}
else {
// array of scalar values
form.change(key + "[" + index + "]", value);
}
});
}
else {
// scalar value
form.change(key, record[key]);
}
form.resetFieldState(key);
}
});
});
}, [form, JSON.stringify(record)]); // eslint-disable-line react-hooks/exhaustive-deps
};
export default useInitializeFormWithRecord;
Codesandbox with error
Pay attention to the file data.js, where the object id can be text
What you were expecting:
expected data to be displayed inside
<ReferenceArrayInput>
c< AutocompleteArrayInput / >
What happened instead:
The application crashes
Steps to reproduce:
went into debugging and found a file with an error
http://localhost:3001/static/js/C:/_Projects/ASKUG/web-askug-service-portal/node_modules/ra-core/esm/form/useInitializeFormWithRecord.js
Related code:
Codesandbox with error
Pay attention to the file data.js, where the object id can be text
Environment
The text was updated successfully, but these errors were encountered: