# Fix React Version Not Specified in ESLint Plugin React

> Add a react.version setting of detect to your ESLint eslint-plugin-react configuration so it lints against your project's actual React version

**URL:** https://sentry.io/answers/warning-react-version-not-specified-in-eslint-plugin-react-settings-while-running-eslint-on-top-of-react-18-2-0/

---

## The Problem

When using the [`eslint-plugin-react`](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/README.md) ESLint plugin, which adds React-specific linting rules to ESLint, you may encounter the following warning:

```
Warning: React version not specified in eslint-plugin-react settings.
```

## The Solution

This warning occurs if you haven't added the React version to your `eslint-plugin-react` configuration settings. When the React version hasn't been specified in your `eslint-plugin-react` settings, `eslint-plugin-react` defaults to using the latest React version for linting, which may lead to incorrect ESLint warnings or errors if you aren't using the latest React version.

Specify which React version you're using in your `eslint-plugin-react` configuration settings. If you're using the [new ESLint configuration system](https://eslint.org/blog/2022/08/new-config-system-part-2/), modify your `eslint.config.js`, `eslint.config.mjs`, or `eslint.config.cjs` ESLint configuration file to include the React version:

```js
export default [
  {
    settings: {
      react: {
        version: "detect",
        // ...
      },
    },
    // ...
    plugins: ["react"],
    // ...
  },
];
```

When you specify "detect" as the React version, `eslint-plugin-react` automatically uses the React version of your project. You can also set a React version number, such as `16.0`, if you want to override the detected value.

The new configuration system was added in [`ESLint version 8.21.0`](https://github.com/eslint/eslint/releases/tag/v8.21.0). This new system doesn't use the legacy `.eslintrc` config file name and instead uses `eslint.config.js` as the new default config file name. From ESLint version 9 onwards, only the new system is supported.

If you're using an older ESLint version, update your `.eslintrc` file to include the React version:

```
{
  "settings": {
    "react": {
      "version": "detect"
      // ...
    },
    // ...
    "plugins": [
      "react"
    ]
    // ...
  }
}
```

The React default version is configurable from `eslint-plugin-react` [version 7.35.0](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md#added).

### Note

The `React version not specified in eslint-plugin-react settings.` warning was added to `eslint-plugin-react` [version 7.12.0](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/CHANGELOG.md#added) in response to this GitHub issue: [React 16 lifecycle errors appearing in a React 15 project](https://github.com/jsx-eslint/eslint-plugin-react/issues/1789).

---

*Source: [sentry.io/answers/warning-react-version-not-specified-in-eslint-plugin-react-settings-while-running-eslint-on-top-of-react-18-2-0/](https://sentry.io/answers/warning-react-version-not-specified-in-eslint-plugin-react-settings-while-running-eslint-on-top-of-react-18-2-0/)*
