T
TanStack7mo ago
wee-brown

Get fieldMeta from array element

Is there a way to getFieldMeta from an index element and not a subField? For example if I have people[] and need to see if people[i] has any changes within it, there doesn't seem to be meta associated with that. I either have the entire people array isDirty or I can see specific subFields like people[i].name is dirty, but no way to check if a particular element has any changes? I have this which seems to work? But it's super messy...
people
.filter((person, i) => {
const meta = (Object.keys(person) as (keyof typeof person)[]).map((key) =>
formApi.getFieldMeta(`people[${i}].${key}`),
);
return meta.some((meta) => meta?.isDirty);
})
.map((person, i) => {
console.log("dirty", person);
});
people
.filter((person, i) => {
const meta = (Object.keys(person) as (keyof typeof person)[]).map((key) =>
formApi.getFieldMeta(`people[${i}].${key}`),
);
return meta.some((meta) => meta?.isDirty);
})
.map((person, i) => {
console.log("dirty", person);
});
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?