useGridDimensions undefined is not a object

This issue has been tracked since 2023-01-11.

We have been seeing this error crop up in our deployed environments

TypeError undefined is not an object (evaluating 'e[0].contentBoxSize[0]') 
    hooks/useGridDimensions.ts:32:45 

Upon investigating this hook further, it seems that line 32 could be amended from.

const resizeObserver = new ResizeObserver((entries) => {
    const size = entries[0].contentBoxSize[0];
    setInlineSize(size.inlineSize);
    setBlockSize(size.blockSize);
});

To

const resizeObserver = new ResizeObserver(([entry]) => {
	const size = entry?.contentBoxSize?.[0];

	if (size) {
    	setInlineSize(size.inlineSize);
	    setBlockSize(size.blockSize);
	}
});

This would avoid the potential undefined error we're seeing in deployed environments.

Environment

  • react-data-grid version: ^7.0.0-beta.20
  • react/react-dom version: ^17.0.2
More Details About Repo
Owner Name adazzle
Repo Name react-data-grid
Full Name adazzle/react-data-grid
Language TypeScript
Created Date 2015-03-06
Updated Date 2023-03-23
Star Count 5922
Watcher Count 129
Fork Count 2072
Issue Count 161

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date