Jsx is used without importing react

9.9k Views Asked by At

I am getting the

Jsx is used without importing react

Notification by WebStorm even tho I made react library global via:

My webpack.config.js

        plugins: [
            new webpack.ProvidePlugin({
                React: "react"
            })
        ]

My declarations.d.ts

import _React from "react";
declare global {
    const React: typeof _React;
}

It is no error and the code runs fine, but I do not like such an unnecessary notification. How do I tell WebStorm that I did import react globally?

2

There are 2 best solutions below

5
On BEST ANSWER

Just turn the inspection off in Settings | Editor | Inspections | JavaScript and TypeScript | Imports and dependencies, Missing React import with JSX

0
On

September 2022 Update

The setting is now under Editor > Inspections > JavaScript and TypeScript > Imports and dependencies > Missing 'React' namespace import in JSX code

To completely disable this inspection, select No highlighting as the Severity option.

The JetBrains Webstorm code inspection severity settings dropdown