MultiGrid doesn't re-render when data changed
See original GitHub issueWhen using MultiGrid
with non-zero fixedColumnCount
, the content of the fixed column doesn’t get updated when needed. For example, when using with ArrowKeyStepper
it doesn’t display focused cell. At the same time, the cell gets focused in the “main” grid.
Reproducible case
Issue Analytics
- State:
- Created 5 years ago
- Comments:11
Top Results From Across the Web
react-virtualized list item does not re-render with changed ...
In my use case, I allowed the user to sort the data, and the dataset needed to be passed to the MultiGrid so...
Read more >react-virtualized list item does not re-render with changed ...
In my use case, I allowed the user to sort the data, and the dataset needed to be passed to the MultiGrid so...
Read more >Just got resizable columns working on my react-virtualized ...
Resizable columns in a react-virtualized MultiGrid. This is a quick screen recording of my open-source software, D-Tale.
Read more >How to Force-Refresh a React Child Component: The Easy Way
In the React world, forcing a re-render is frowned upon. ... When the user changes their color preference, the server writes new data...
Read more >Rendering large lists with React Virtualized - LogRocket Blog
It manages the fetching of data as a user scrolls a List, Table, or Grid. MultiGrid. It decorates a Grid component to add...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
how would you do this for a functional component using hooks, or is this not possible with react pure components? i’ve made a virtualized Grid with hooks and functional components but it won’t re-render with state change.
I think there is a better way than manually using
forceUpdateGrids
.What is happening here is cell rendering control is being deferred to
MultiGrid
.MultiGrid
andGrid
are bothPureComponent
s, so they will only update when their props change value/reference.The component consuming
MultiGrid
probably has other props that its cells should update for, butMultiGrid
doesn’t necessarily know that, it only updates when the props it has change.One easy fix is to just spread the
props
from the component consumingMultiGrid
. It’s definitely confusing, becauseMultiGrid
will be passed props that it doesn’t need. But since the cell rendering control is being deferred, we have to ensure thatMultiGrid
will actually update when we want it to.For example:
In this example, let’s say the
props.className
changed forMyGridComponent
. The expected behavior is that each cell will get a newclassName
. ButclassName
is not passed toMultiGrid
, so it will not update (because it’s aPureComponent
) and it won’t re-render the cells.If we change
render
to pass the props, then the cells will be updated as expected: