# component-hook-factories

Rule `react-hooks/component-hook-factories`. Deprecated: this rule has been removed in 7.1.0.

- Source: react-hooks
- Technologies: React
- Kind: correctness
- Needs type information: no
- Autofix: no
- Deprecated: yes
- Reach: 30.6M weekly downloads of presets that enable it
- Trend: +109.3% last quarter
- Rank: #479 by reach, #114 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `react-hooks/component-hook-factories` | no | no | package `eslint-plugin-react-hooks` | [docs](https://react.dev/reference/eslint-plugin-react-hooks/lints/component-hook-factories) |
| Biome | `correctness/noComponentHookFactories` | yes | no | group correctness, since 2.4.12 | [docs](https://biomejs.dev/linter/rules/no-component-hook-factories/) |

## Code examples

### Incorrect: the rule reports this

```js
function createComponent(defaultValue) {
  return function Component() {
    // ...
  };
}
```

```js
function Parent() {
  function Child() {
    // ...
  }

  return <Child />;
}
```

```js
function createCustomHook(endpoint) {
  return function useData() {
    // ...
  };
}
```

### Correct: the rule accepts this

```js
function Component({ defaultValue }) {
  // ...
}
```

```js
function useData(endpoint) {
  // ...
}
```

```js
function Button({color, children}) {
  return (
    <button style={{backgroundColor: color}}>
      {children}
    </button>
  );
}

function App() {
  return (
    <>
      <Button color="red">Red</Button>
      <Button color="blue">Blue</Button>
    </>
  );
}
```

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/component-hook-factories": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "correctness": {
        "noComponentHookFactories": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |

## Related rules

- [react-hooks/gating](https://lintradar.dev/rules/react-hooks/gating.md): Validates configuration of gating mode
- [react-hooks/config](https://lintradar.dev/rules/react-hooks/config.md): Validates the compiler configuration options
- [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/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/static-components](https://lintradar.dev/rules/react-hooks/static-components.md): Validates that components are static, not recreated every render. Components that are recreated dynamically can reset state and trigger excessive re-rendering
- [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

---

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