react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

Subset of data is rendering before it renders completely.

Open goughfey opened this issue 3 months ago • 8 comments

I am using latest version of react-data-grid in nextjs version 16.0.0. Issue is that when I reload the page the data is rendering in blinking way which is bad ux.

https://github.com/user-attachments/assets/9f8c7977-91bc-4907-be05-e1ba525d9cd0

goughfey avatar Oct 23 '25 01:10 goughfey

Is this starting happening with nextjs 16? It does not happen on the example website

amanmahajan7 avatar Oct 23 '25 18:10 amanmahajan7

it is working fine for react-router or tanstack-router but this is happening in nextjs 15 as well...

goughfey avatar Oct 24 '25 15:10 goughfey

Are you seeing this in both dev and prod modes? What browser are you using?

nstepien avatar Oct 24 '25 15:10 nstepien

I am using firefox and chrome and same issue on both browsers and both environments...

goughfey avatar Oct 24 '25 15:10 goughfey

I'm guessing we're only rendering a few cells in SSR, and the browser renders the SSR content before React can kick in? Not sure there's an ideal workaround, maybe we could avoid rendering any cells at all in SSR?

nstepien avatar Oct 24 '25 16:10 nstepien

What is purpose of rendering few cells in ssr?

htmujahid avatar Oct 24 '25 16:10 htmujahid

https://github.com/Comcast/react-data-grid/blob/main/src/hooks/useGridDimensions.ts#L6-L7 When DataGrid renders for the first time, we don't know the dimensions of the grid until we mount the DOM and measure the grid, only then can the grid know how many columns/rows can be safely rendered.

nstepien avatar Oct 24 '25 16:10 nstepien

Maybe another workaround is to disable virtualization in SSR and render a few rows

<DataGrid 
  enableVirtualization={!isSSR} // not sure if there is a flag like that 
  rows={isSSR > rows.slice(0, 50): rows}

amanmahajan7 avatar Oct 24 '25 17:10 amanmahajan7