ESLint asks for a React import that the automatic JSX runtime does not need
Fix it fast
Most common cause, 1 of 3The jsx-runtime config of eslint-plugin-react is missing
Add the jsx-runtime preset right after recommended.
// eslint.config.js
import reactPlugin from 'eslint-plugin-react';
export default [
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat['jsx-runtime'],
];
// .eslintrc.json (legacy config)
{ "extends": ["eslint:recommended", "plugin:react/recommended", "plugin:react/jsx-runtime"] }Short answer
'React' must be in scope when using JSX is the ESLint rule react/react-in-jsx-scope, written for the classic React.createElement transform. With the automatic JSX runtime, which React 19 requires, no import is needed: add eslint-plugin-react's jsx-runtime config after recommended. Version 7.37.5 does not switch the rule off for React 19 by itself.
Which cause do you have?
Ask ESLint for the final config of one flagged file and look at the rule's severity. 2 (error) or 1 (warn) means the rule is still active, which is cause 1 or 2. Then look at how the build compiles JSX: a classic setting there is cause 3.
npx eslint --print-config src/App.jsx | grep -A2 "react-in-jsx-scope"
grep -n '"jsx"' tsconfig.json
grep -rn "runtime" babel.config.* .babelrc 2>/dev/nullThen find the line you see in this list and open its fix:
- 1The jsx-runtime config of eslint-plugin-react is missing
The config spreads reactPlugin.configs.flat.recommended (or extends plugin:react/recommended) and nothing named jsx-runtime appears in it - 2A later config object switches the rule back on
jsx-runtime is present in eslint.config.js, yet --print-config still reports severity 2 - 3The build still compiles JSX with the classic transform
tsconfig.json has "jsx": "react", or Babel sets runtime: "classic", and the browser console shows the outdated JSX transform warning
What does the error look like?
'React' must be in scope when using JSX react/react-in-jsx-scope'React' must be in scope when using JSXYour app (or one of its dependencies) is using an outdated JSX transform.
Cause 1 of 3
The jsx-runtime config of eslint-plugin-react is missing
You seeThe config spreads reactPlugin.configs.flat.recommended (or extends plugin:react/recommended) and nothing named jsx-runtime appears in it
Check
ESLint raises 'React' must be in scope when using JSX because the recommended preset of eslint-plugin-react turns react/react-in-jsx-scope on, and only the separate jsx-runtime preset turns it off. The plugin's changelog lists an automatic switch-off for React 19 under Unreleased, so the published 7.37.5 still flags every JSX file without a React import.
grep -n "configs.flat\|plugin:react" eslint.config.* .eslintrc* 2>/dev/nullFix
Add the jsx-runtime preset right after recommended. In a legacy .eslintrc file the equivalent is the plugin:react/jsx-runtime entry in extends.
// eslint.config.js
import reactPlugin from 'eslint-plugin-react';
export default [
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat['jsx-runtime'],
];
// .eslintrc.json (legacy config)
{ "extends": ["eslint:recommended", "plugin:react/recommended", "plugin:react/jsx-runtime"] }Verify
The printed config now shows the rule at 0, and a lint run no longer lists it.
npx eslint --print-config src/App.jsx | grep -A2 "react-in-jsx-scope"
npx eslint src/Confirmed by raw.githubusercontent.com
Cause 2 of 3
A later config object switches the rule back on
You seejsx-runtime is present in eslint.config.js, yet --print-config still reports severity 2
Check
The jsx-runtime preset can be cancelled by whatever comes after it. ESLint merges every config object that matches a file, and on a conflict the later object wins, so recommended spread after jsx-runtime, or a rules block that sets react/react-in-jsx-scope to error, brings the message back.
grep -n "jsx-runtime\|recommended\|react-in-jsx-scope" eslint.config.*Fix
Put jsx-runtime after every React preset, or end the array with an object that turns the rule off for your JSX files.
export default [
reactPlugin.configs.flat.recommended,
// ...other presets and your own rules
reactPlugin.configs.flat['jsx-runtime'],
{
files: ['**/*.{jsx,tsx}'],
rules: { 'react/react-in-jsx-scope': 'off' },
},
];Verify
The printed config reports the rule at 0. If it does not, the config inspector started by --inspect-config shows which objects still apply to the file.
npx eslint --print-config src/App.jsx | grep -A2 "react-in-jsx-scope"
npx eslint --inspect-configConfirmed by eslint.org
Cause 3 of 3
The build still compiles JSX with the classic transform
You seetsconfig.json has "jsx": "react", or Babel sets runtime: "classic", and the browser console shows the outdated JSX transform warning
Check
Here the ESLint message is right: with the classic transform each JSX element compiles to a React.createElement call, which needs React imported in that file. React 19 needs the automatic runtime for features such as ref as a prop and warns that the app is using an outdated JSX transform. In TypeScript the value react means classic and react-jsx means automatic; Babel 8 made automatic the default, while Babel 7 defaulted to classic.
grep -n '"jsx"' tsconfig.json
grep -rn "runtime" babel.config.* .babelrc 2>/dev/nullFix
Switch the compiler to the automatic runtime, then apply the ESLint change from cause 1. Imports of React that only served JSX can then go.
// tsconfig.json
{ "compilerOptions": { "jsx": "react-jsx" } }
// babel.config.json (Babel 7 needs it spelled out)
{ "presets": [["@babel/preset-react", { "runtime": "automatic" }]] }Verify
Restart the dev server: the outdated JSX transform warning is gone from the console and ESLint is quiet about the rule.
npx eslint src/Confirmed by react.dev
How do I stop it coming back?
- Keep the jsx-runtime preset as the last React entry in eslint.config.js and leave a comment saying why it must stay last.
- Run npx eslint --print-config on one component in CI and fail the job if react-in-jsx-scope is not 0.
- Set the JSX mode once (tsconfig jsx or the Babel preset runtime) and avoid per-file /** @jsx */ pragmas that switch single files back to classic.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: TaxiDex, QistLock, Taskvare.