Skip to content

Commit

Permalink
Fix potential "ResizeObserver loop limit exceeded" error
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Apr 11, 2023
1 parent 2f3c476 commit 12ddd48
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/AutoSizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ export class AutoSizer extends Component<Props, State> {
// See issue #41
if (this._parentNode != null) {
if (typeof ResizeObserver !== "undefined") {
this._resizeObserver = new ResizeObserver(this._onResize);
this._resizeObserver = new ResizeObserver(() => {
// Guard against "ResizeObserver loop limit exceeded" error;
// could be triggered if the state update causes the ResizeObserver handler to run long.
// See https://github.com/bvaughn/react-virtualized-auto-sizer/issues/55
setTimeout(this._onResize, 0);
});
this._resizeObserver.observe(this._parentNode);
} else {
this._detectElementResize = createDetectElementResize(
Expand Down

0 comments on commit 12ddd48

Please sign in to comment.