# only-export-components

Rule `react-refresh/only-export-components`. Validate that your components can safely be updated with Fast Refresh

- Source: react-refresh
- Technologies: React
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1767 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `react-refresh/only-export-components` | no | no | package `eslint-plugin-react-refresh` | [docs](https://github.com/ArnaudBarre/eslint-plugin-react-refresh#readme) |
| Biome | `style/useComponentExportOnlyModules` | no | no | group style, since 1.9.2 | [docs](https://biomejs.dev/linter/rules/use-component-export-only-modules/) |

## Code examples

### Incorrect: the rule reports this

```jsx
export const foo = () => {};
export const Bar = () => <></>;
```

```jsx
export default function () {}
export default compose()(MainComponent)
```

```jsx
export * from "./foo";
```

### Correct: the rule accepts this

```jsx
export default function Foo() {
  return <></>;
}
```

```jsx
const foo = () => {};
export const Bar = () => <></>;
```

```jsx
import { App } from "./App";
createRoot(document.getElementById("root")).render(<App />);
```

Examples from the ESLint documentation.

## Enable it

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

```js
import reactRefresh from "eslint-plugin-react-refresh";

export default [
  {
    plugins: { "react-refresh": reactRefresh },
    rules: {
      "react-refresh/only-export-components": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "style": {
        "useComponentExportOnlyModules": "error"
      }
    }
  }
}
```

## Related rules

- [react/only-export-components](https://lintradar.dev/rules/react/only-export-components.md): Ensures that modules only **export React components (and related HMR-safe items)** so that Fast Refresh (a.k.a. hot reloading) can safely preserve component state. Concretely, it validates the shape of your module’s exports and common entrypoints (e.g. `createRoot(...).render(<App />)`) to match what integrations like `react-refresh` expect.

---

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