Home | javascript

Unused variable eslint error in react component


If you are working with react and uses eslint for linting your code, you may get the following error

import Nav from './nav'

The above code will throw unused variable error eventhough it is used in render.


Create a .eslintrc.json file, if you dont have already, add the following lines

  "rules": {
    "react/jsx-uses-vars": 1