You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to be able cache to rows from within custom renderCell components. For example:
renderCell: ({ row })=>{const{ id, _calc_status }=rowconst[state,setState]=useState({...,loading: true,status: _calc_status})useEffect(()=>{asyncfunctioninit(){if(_calc_status)returnconstres=awaitfetch(...)// actually await dataLoader.load(id) because I know not to fire off hundreds of separate requestsconststatus=res.etc.etc.setState(state=>({...state, status,loading: false}))row={...row,_calc_status: status}}init()},[id])return(<Divsx={{width: '100%',display: 'flex',justifyContent: 'flex-start',alignContent: 'center',}}>{state.loading ? <CircularProgresssize={12}/> : state.status}</Div>)}
Proposed solution
Please let me know if there is a good way to do this already - I don't think I want to reset the whole rows array, but setting row doesn't seem to work.
The above actually works (without setting row, in that I can performantly used cached values set in the state). But the values in the cell don't display quite as smoothly as other columns - if i scroll fast then the values appear slightly late.
I think this is because rows outside outside of the virtualized area are pre-rendered based on key? (so in other words for these rows the render key will never have data). Or, at least this isn't a problem if I disable virtualization
Aside from the very minor UI glitch when rendering rows using my current approach, if I could cache onto rows then I would (I hope) be able to sort on this column using the cached value
The text was updated successfully, but these errors were encountered:
zachsa
changed the title
Request to be able to cache to row object from custome renderCell component
Request to be able to cache to row object from custom renderCell component
Aug 30, 2024
Use case
I would like to be able cache to rows from within custom
renderCell
components. For example:Proposed solution
Please let me know if there is a good way to do this already - I don't think I want to reset the whole rows array, but setting row doesn't seem to work.
The above actually works (without setting row, in that I can performantly used cached values set in the state). But the values in the cell don't display quite as smoothly as other columns - if i scroll fast then the values appear slightly late.
I think this is because rows outside outside of the virtualized area are pre-rendered based on key? (so in other words for these rows the render key will never have data). Or, at least this isn't a problem if I disable virtualization
Aside from the very minor UI glitch when rendering rows using my current approach, if I could cache onto rows then I would (I hope) be able to sort on this column using the cached value
The text was updated successfully, but these errors were encountered: