Helper method on row models are not referentially stable on data change #5885
Unanswered
yanlin-duan
asked this question in
Q&A
Replies: 0 comments
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
I realize that when data changes, the
toggleExpanded
method defined on row object changes as well, even though the expand toggle behavior should have nothing to do with the data. In this example: https://codesandbox.io/p/devbox/gracious-surf-k8vc7y, if you click on "Refresh data", we will change the first name of the name on the first row. However, this seems to lead to a newrow
object created for every single row, andtoggleExpanded
on each row is also a new function. The implication is we can't, for instance, properly memoize a component and avoid re-rendering it due totoggleExpanded
being unstable.From what I see in the source code, this toggleExpanded function doesn't really rely on any fields on data. Is there a reason why we don't memoize it similar to how we memo other methods?
Beta Was this translation helpful? Give feedback.
All reactions