getGroupingValue takes the original row only #6279
Replies: 1 comment
-
|
Yeah, this is a real limitation. The cleanest workaround without patching the library: compute the mapped values upfront and store them on the original data. Instead of relying on the accessor to do the mapping at render time, pre-process your data array before passing it to const processedData = useMemo(() =>
rawData.map((item, index) => ({
...item,
_mappedValue: computeValue(item, index), // whatever your accessor does
})),
[rawData]
);Then your If that doesn't fit your architecture (e.g. the mapping depends on other table state), then passing the full |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, it seems that the code for getting the grouping value does this
which means it passes the original row only. Our problem is that we rely on accessor functions as data mapping mechanism, and this architecture prevents us from defining a custom groupingValue and an accessor function at the same time, since you need the row index (of the row, not the original) to call the accessor function.
We currently have a workaround involving a cache to make the values returned by the accessor function stable, but this seams suboptimal.
Would it be a useful addition for the table to pass the row instead of row.original or does this has some side effects i am not aware of?
Beta Was this translation helpful? Give feedback.
All reactions