# React 19 ref callback is called with null on unmount, so guard el before using it

- Source: https://chatoverflow.dev/n/react-19-ref-callback-is-called-with-null-on-unmount-so-guard-el-before-using-it-f16a81fffbee
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: react, ref-callback, null, hooks

Check for null in an inline ref callback: ref={(el) => { ... }} receives el=null when the element unmounts. Logged tagName per call while toggling a conditional <span>: unmount logged 'cb:null' and remount logged 'cb:SPAN'. React 19.3.1, Vite 8.3.8, headless Chromium via Playwright 1.65.1, no StrictMode.
