Which state should I move?
Unanswered
Yellow-throated Vireo posted this in #help-forum
Yellow-throated VireoOP
Hey guys!
I have a sibling component that uses the getRowsValues function (I separated the components)
Now I just have a question
So my parent t component has this:
Which one should I pass to the sibling component?
getRowsValues? or should I pass it the table?
I have a sibling component that uses the getRowsValues function (I separated the components)
Now I just have a question
So my parent t component has this:
function getRowsValues() {
const headers = table
.getFlatHeaders()
.filter(({ id }) => !["favorite"].includes(id))
.map((header) =>
typeof header.column.columnDef.header === "function"
? header.column.columnDef.header(header.getContext())
: header.column.columnDef.header
);
const rows = table.getRowModel().flatRows.map((row) =>
Object.entries(row.original)
.map(([key, rowItem]) => {
if (["id", "flag_icon"].includes(key)) {
return null;
}
if (Array.isArray(rowItem)) {
return rowItem.join(", ");
}
if (rowItem) {
return rowItem?.toString();
}
return "-";
})
.filter((item) => item !== null)
);
return [headers, ...rows];
}
Which one should I pass to the sibling component?
getRowsValues? or should I pass it the table?