Skip to content

Commit

Permalink
fix: Fix model can be null (#422)
Browse files Browse the repository at this point in the history
We're getting this error in prod. Could only be because getModel() is returning null

Cannot read properties of undefined (reading 'isRowsToRender')
  • Loading branch information
matttdawson authored Sep 13, 2023
1 parent 6bcc810 commit ad3f393
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/contexts/GridContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ export const GridContextProvider = <RowType extends GridBaseRow>(props: PropsWit
* Used to check if it's OK to autosize.
*/
const gridRenderState = useCallback((): null | "empty" | "rows-visible" => {
if (!gridApi) return null;
// Even though getModel can't be null, sometimes it is
if (!gridApi || !gridApi.getModel()) return null;
if (!gridApi.getModel().isRowsToRender()) return "empty";
if (!isEmpty(gridApi.getRenderedNodes())) return "rows-visible";
// If there are rows to render, but there are no rendered nodes then we should wait
Expand Down

0 comments on commit ad3f393

Please sign in to comment.