question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unused variable warning in JSX files

See original GitHub issue

When 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:closed
  • Created 8 years ago
  • Reactions:17
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

44reactions
fiatjafcommented, Jun 3, 2017

If you are lost like I was, this is how and where you put this stupid rule “jsx-uses-vars”, after installing the plugin:

"rules": {
  "react/jsx-uses-vars": 2,
}
17reactions
lo1tumacommented, Jun 13, 2016

@macgyver I think you need to enable the jsx-uses-vars rule.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found