I am new to react, although my app is working just fine but my app.jsx is showing an error. A redline appears beneath the react word and when I am hovering the mouse pointer over it, it is saying "react is define but never used" Can any one of you help me, i am attaching the screenshot below
I am very new to react, i don’t understand why there is an redline beneath the react word although my app is working just fine. I don’t understand why my editor is showing a redline beneath the word react, it is saying that react was defined but never used.
2
Answers
To resolve this, you have two options:
Keep the import and ignore the warning:
You can keep your current import import React from ‘react’ and simply ignore the warning. Your app will continue to work fine.
Remove the import (recommended for newer React versions):
If you’re using React 17 or later with a modern build setup, you can remove the React import entirely. The JSX transform in newer versions doesn’t require you to import React for just using JSX.
Your App.jsx file would then look like this:
This warning is just a linter suggestion and doesn’t affect your app’s functionality. It’s trying to help you keep your code clean by pointing out unused imports.
To resolve this, either use React in your code or remove the import statement if it’s unnecessary.