๐ฅ ResizeObserver Error in React
(Why it appears only in DEV and scares everyone ๐ฑ)
" Uncaught runtime errors:
ResizeObserver loop completed with undelivered notifications " If you have ever seen this red screen suddenly appear while scrolling, resizing, or editing an AG Grid…
๐ Welcome to the ResizeObserver Club ๐
๐ค What is ResizeObserver?
ResizeObserver is a browser API that watches:
- Element width changes
- Element height changes
- Layout recalculations
Modern UI libraries like:
- AG Grid
- Material UI
- Ant Design
use ResizeObserver heavily to keep layouts perfect.
AG Grid uses it a LOT ๐
๐ What does this error actually mean?
In simple words:
"Hey browser, I tried to recalculate layout again and again…
but UI kept changing continuously ๐ค"
So the browser says:
"Enough! I’m stopping this infinite resize loop." ๐ฅ
๐ง Real Reasons Why This Happens (AG Grid Edition)
1️⃣ Dynamic height inside CellRenderer
Example:
Height keeps changing → ResizeObserver keeps firing ๐
2️⃣ autoHeight + long wrapping text
When you combine:
- autoHeight
- white-space: normal
- long text
AG Grid tries to measure height repeatedly.
Result: ๐ฅ ResizeObserver error
3️⃣ Missing getRowId (VERY COMMON)
Without this:
getRowId={(params) => params.data.id}AG Grid thinks:
"One cell changed? Let me re-render EVERYTHING" ๐
ResizeObserver gets overwhelmed.
4️⃣ Custom dropdowns floating outside grid
When dropdowns are:
- position: absolute
- Rendered outside grid DOM
Scrolling + resize = chaos ๐ฅ
๐คฏ Why this happens ONLY in DEV?
This is the most confusing part.
✅ Reason 1: React StrictMode
In DEV mode:
- Components render twice
- Effects run twice
React does this intentionally to catch bugs.
Production build:
๐ Clean
๐ Single render
๐ No red screen
✅ Reason 2: DEV shows runtime overlay
DEV environment shows:
- Warnings as full-screen errors
- ResizeObserver warnings aggressively
Production:
๐ Console warning only
๐ UI continues working
✅ Reason 3: Slower DEV rendering
DEV mode is slower.
Slow rendering + heavy DOM = resize timing issues
๐ ️ Correct Ways to Fix (Production Safe)
✔ Fix 1: Always define getRowId
<AgGridReact
getRowId={(params) => params.data.id}
/>✔ Fix 2: Avoid dynamic height changes
// ✅ Better
<div style={{ minHeight: 32 }}>
<Dropdown hidden={!checked} />
</div>✔ Fix 3: Use AG Grid built-in editors
Instead of custom dropdowns:
cellEditor: 'agSelectCellEditor'AG Grid handles:
- Scroll
- Resize
- Close on blur
✔ Fix 4: Suppress ResizeObserver safely
<AgGridReact
suppressBrowserResizeObserver={true}
stopEditingWhenCellsLoseFocus={true}
/>✔ Officially supported
๐ Developer Joke (True Story)
"It works in production, so ignore DEV error"
— Famous words before next sprint ๐
๐ง Golden Rules to Avoid This Forever
- ✔ Stable row IDs
- ✔ Avoid height-changing DOM
- ✔ Prefer AG Grid editors
- ✔ Avoid re-setting full rowData
๐ Wrapping Up
ResizeObserver error is not a bug — it’s a signal.
It tells you:
- Your UI is doing too much resizing
- Your grid needs stability
Fix the cause, not the warning.
๐ฌ If you faced this issue and fixed it differently, share your experience — someone else is debugging this right now ๐
Comments
Post a Comment