react-doctor/no-unguarded-browser-global-in-render-or-hook-init
Browser global read during server render
- Category: Bugs
- Severity: error
- Source:
oxlint-plugin-react-doctor - Framework: global
- Enabled when: react, ssr
- Default: Enabled
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Confirm the reported code matches Browser global read during server render. Check the framework context and diagnostic message before suppressing it.
Fix prompt
Use this once validation confirms the diagnostic is real.
Move browser-only reads into an effect or event, guard them behind a client-only render path, or use useSyncExternalStore with a stable server snapshot.
Related rules
More Bugs rules from the rules reference:
react-doctor/no-unknown-property: Disallow unknown or mis-cased DOM attributes in JSX, like class instead of className.react-doctor/no-unsafe: Replace UNSAFE_componentWillMount / WillReceiveProps / WillUpdate with their modern lifecycle equivalents.react-doctor/no-will-update-set-state: Don't call this.setState in componentWillUpdate — move the update to getDerivedStateFromProps or componentDidUpdate.react-doctor/preact-no-children-length: Wrap with toChildArray(children) from preact before reading .length or calling array methods on props.children.react-doctor/preact-no-react-hooks-import: Import hooks from `preact/hooks` (or `preact/compat`), not `react`: import { useState } from "preact/hooks"