Root cause: the React DevTools browser extension injects a hook stub at
document_start (before HTML parsing), so hook.inject can be undefined
when React Fast Refresh runs. React Refresh destructures inject as
undefined and later calls undefined.apply() -> TypeError. This prevents
React from ever setting injectedHook, so onCommitFiberRoot is never called.
Fix: unconditionally replace hook.inject with a wrapper that tries the
captured previous inject (with try/catch) then falls back to our own
renderer ID allocation. Works regardless of script execution order.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>