react-doctor/no-ref-current-in-render
Ref mutated during render
- Category: Bugs
- Severity: error
- Source:
oxlint-plugin-react-doctor - Framework: global
- Enabled when: react
- Default: Enabled
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Confirm the reported code matches Ref mutated during render. Check the framework context and diagnostic message before suppressing it.
Fix prompt
Use this once validation confirms the diagnostic is real.
Move ref writes into an event handler or effect. Render must stay pure because React can replay or discard it. The predictable null-guarded lazy initialization pattern remains supported.
Related rules
More Bugs rules from the rules reference:
react-doctor/no-render-return-value: Disallow using the return value of ReactDOM.render — a legacy escape hatch removed in React 19.react-doctor/no-reset-all-state-on-prop-change: Disallow resetting all state in an effect when a prop changes.react-doctor/no-self-updating-effect: Break the self-updating-effect feedback loop: derive the value during render, move the write into an event handler, or guard the update so it provably converges.react-doctor/no-set-state-in-render: Move the setter call into a `useEffect`, an event handler, or replace the state with a value computed during render. Calling a setter at render time triggers another render, which calls the setter again — an infinite loopreact-doctor/no-stale-timer-ref: Cleared timer ref keeps the stale id