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
{{ message }}
Repository navigation
Uncaught TypeError "Cannot read properties of null (reading 'isDestroyed')" in onSortChanged when a grid initializes with initialState sortModel #466
When a grid is created with a sort applied at init time (e.g. via dashGridOptions.initialState.sort.sortModel), the browser console
shows an uncaught TypeError at grid creation:
AgGrid.react.js:735 Uncaught TypeError: Cannot read properties of
null (reading 'isDestroyed')
at AgGrid.react.js:735:22
at main.esm.mjs:41889:13
at qS.wrapOutgoing (main.esm.mjs:34897:39)
...
at j.flushAsyncQueue (main.esm.mjs:114:15)
One error is emitted per grid that has an initial sort. The error is
benign in practice (only the first columnState sync back to Dash is
skipped for that event; subsequent sortChanged events work normally),
but it pollutes the console on every page load.
Environment
dash-ag-grid 32.3.2 (also verified present in 32.3.4 and 35.2.0
sources, see below)
dash 4.0.0
AG Grid community v32 (bundled)
Chrome, macOS
Root cause
In src/lib/fragments/AgGrid.react.js, the onSortChanged handler is
the only event handler that dereferences gridApi without a null
guard (v32.3.2 line 735; still identical in v35.2.0 line 754):
constonSortChanged=useCallback(()=>{const{rowModelType}=props;constpropsToSet={};if(rowModelType==='clientSide'){propsToSet.virtualRowData=virtualRowData();}if(!gridApi.isDestroyed()){// <-- gridApi can be null herepropsToSet.columnState=JSON.parse(JSON.stringify(gridApi.getColumnState()));}customSetProps(propsToSet);},[props.rowModelType,virtualRowData,gridApi,customSetProps]);
All sibling handlers use the guarded form gridApi && !gridApi?.isDestroyed() (e.g. onPaginationChanged, onRowDataUpdated), and updateColumnState has an early if (!gridApi) return;.
Why gridApi is null when the handler fires: AG Grid v32 dispatches
grid events asynchronously (dispatchAsync -> setTimeout ->
flushAsyncQueue). When a grid initializes with a sort (initialState
sortModel), a sortChanged event is queued during grid creation
(ColumnApplyStateService dispatches it when applying the initial sort
state). The queue is flushed on a setTimeout tick that can run before
React has committed the setGridApi state update from onGridReady,
so the onSortChanged closure still sees gridApi === null and the
unguarded gridApi.isDestroyed() throws.
Load the page with the browser console open: the TypeError appears
once at grid creation. With two such grids in the layout, it appears
twice, with identical stacks.
Note: the error does NOT depend on persisted column state
(localStorage cleared -> error unchanged); any sort applied at grid
init triggers it.
Suggested fix
Align onSortChanged with the guard used by every other handler:
if(gridApi&&!gridApi?.isDestroyed()){
The same unguarded line is still present in the latest sources
(v35.2.0, src/lib/fragments/AgGrid.react.js:754), so the fix applies
to the current line as well as the 32.x maintenance branch.
Activity
AnnMarieW commentedon Jun 10, 2026
Hi @timegates-code
Thanks for reporting. The suggested fix looks correct. We would welcome a PR for this if you would like to to one.
camdecoster commentedon Jun 25, 2026
Fixed in #467, which updated the
v35branch.Fix uncaught TypeError in onSortChanged when grid initializes with a …