Unused variable warning in JSX files
See original GitHub issueWhen a variable is only used in a JSX tag expression, I’m getting a no-unused-vars
warning. My rule config is set to
"no-unused-vars": [1, {
"vars": "all",
"args": "none"
}],
Here’s an example of the warning:
var React = require('react');
var Text = require('./Text'); // "Text is defined but never used no-unused-vars"
var Test = React.createClass({
render: function() {
return (
<Text>Hello</Text>
);
}
});
module.exports = Test;
Issue Analytics
- State:
- Created 8 years ago
- Reactions:17
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Turn off error for unused variables during React Development
To turn off reporting error for unused locals, we can set it to false manually and save tsconfig.json. Then make changes on react...
Read more >How to Fix React JS Unused variable like below shown?
I created a new ReactJS app and corded it as below. It doesn't work. I need const person call into const app, How...
Read more >Assigned a Value but Never Used | React JS Debugging
Assigned a Value but Never Used | No Unused Vars | React JS Debugging | Eslint Warnings & Errors.
Read more >VS Code tips — Unused variable highlighting for JavaScript ...
Today's VS Code tip: nused variable highlightingJavaScript and TypeScript unused variables, arguments, and private properties/methods are ...
Read more >React Hooks Warnings (unused variables) - Sonar Community
React. I'm getting many warnings related to variables not being used. These are hooks setters and getters. For example:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you are lost like I was, this is how and where you put this stupid rule “jsx-uses-vars”, after installing the plugin:
@macgyver I think you need to enable the
jsx-uses-vars
rule.