# static-components

Rule `react-hooks/static-components`. Validates that components are static, not recreated every render. Components that are recreated dynamically can reset state and trigger excessive re-rendering

- Source: react-hooks
- Technologies: React
- Kind: correctness
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 165.2M weekly downloads of presets that enable it
- Trend: +28.2% last quarter
- Rank: #103 by reach, #1352 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `react-hooks/static-components` | yes | safe | package `eslint-plugin-react-hooks` | [docs](https://react.dev/reference/eslint-plugin-react-hooks/lints/static-components) |
| Oxlint | `react/static-components` | no | no | plugin `react`, category correctness | [docs](https://oxc.rs/docs/guide/usage/linter/rules/react/static-components.html) |

## Code examples

### Incorrect: the rule reports this

```js
function Parent() {
  const ChildComponent = () => { // New component every render!
    const [count, setCount] = useState(0);
    return <button onClick={() => setCount(count + 1)}>{count}</button>;
  };

  return <ChildComponent />; // State resets every render
}
```

```js
function Parent({type}) {
  const Component = type === 'button'
    ? () => <button>Click</button>
    : () => <div>Text</div>;

  return <Component />;
}
```

```js
function Parent() {
  const [theme, setTheme] = useState('light');

  function ThemedButton() { // Recreated every render!
    return (
      <button className={theme}>
        Click me
      </button>
    );
  }

  return <ThemedButton />;
}
```

### Correct: the rule accepts this

```js
const ButtonComponent = () => <button>Click</button>;
const TextComponent = () => <div>Text</div>;

function Parent({type}) {
  const Component = type === 'button'
    ? ButtonComponent  // Reference existing component
    : TextComponent;

  return <Component />;
}
```

```js
function ThemedButton({theme}) {
  return (
    <button className={theme}>
      Click me
    </button>
  );
}

function Parent() {
  const [theme, setTheme] = useState('light');
  return <ThemedButton theme={theme} />;
}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import reactHooks from "eslint-plugin-react-hooks";

export default [
  {
    plugins: { "react-hooks": reactHooks },
    rules: {
      "react-hooks/static-components": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "react"
  ],
  "rules": {
    "react/static-components": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [React Hooks recommended](https://lintradar.dev/presets/react-hooks-recommended.md) | ESLint | `eslint-plugin-react-hooks` | 16 | 118.4M | +21.5% |
| [Next.js Core Web Vitals](https://lintradar.dev/presets/next-core-web-vitals.md) | ESLint | `eslint-config-next` | 62 | 46.8M | +48.8% |

## Related rules

- [react-hooks/set-state-in-render](https://lintradar.dev/rules/react-hooks/set-state-in-render.md): Validates against setting state during render, which can trigger additional renders and potential infinite render loops
- [react-hooks/unsupported-syntax](https://lintradar.dev/rules/react-hooks/unsupported-syntax.md): Validates against syntax that we do not plan to support in React Compiler
- [react-hooks/set-state-in-effect](https://lintradar.dev/rules/react-hooks/set-state-in-effect.md): Validates against calling setState synchronously in an effect. This can indicate non-local derived data, a derived event pattern, or improper external data synchronization.
- [react-hooks/use-memo](https://lintradar.dev/rules/react-hooks/use-memo.md): Validates usage of the useMemo() hook against common mistakes. See `useMemo()` docs for more information.
- [react-hooks/refs](https://lintradar.dev/rules/react-hooks/refs.md): Validates correct usage of refs, not reading/writing during render. See the "pitfalls" section in `useRef()` usage
- [react-hooks/config](https://lintradar.dev/rules/react-hooks/config.md): Validates the compiler configuration options

---

Web page: https://lintradar.dev/rules/react-hooks/static-components. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
