-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting no-unused-vars for "render" and imported components #1146
Comments
Can you provide the exact linting errors you're getting? |
Sure, they are:
|
My guess is if you fix the real error on line 2, the false error on line 6 will disappear. |
I'm not sure I follow how line 2 is an error. I import the function in 2 then call it in what is line 22 of the file, inside the Home class declaration. |
That isn't calling anything; that's defining a method named "render" on your class, which React calls for you. You don't need to import a render method. |
Removing that line did not solve the Button component import issue. |
K, one more confirmation - if you name Button as anything else - specifically, something that if lowercase wouldn't be an HTML tag name - do you still get the error? If not, it should be a straightforward bug for us to fix :-) |
I'm getting the error on all my component imports, just highlighted that one since it included the render one as well. Here's another example:
and it throws the errors:
|
Looking at your You can also use the recommended configuration. |
That was the solve, thank you. Please close as you see fit. |
does removing un used imports have any impact on building and package size of create react apps ? |
It would have impact on bundle size for any app, including CRA - although treeshaking may mitigate that a bit. |
I've installed eslint and eslint-plugin-react. During eslint --init I said yes that I am using React and have the following .eslintrc file:
module.exports = { "env": { "browser": true, "es6": true }, "extends": "eslint:recommended", "parserOptions": { "ecmaFeatures": { "experimentalObjectRestSpread": true, "jsx": true }, "sourceType": "module" }, "plugins": [ "react" ], "rules": { "indent": [ "error", 4 ], "linebreak-style": [ "error", "unix" ], "quotes": [ "error", "single" ], "semi": [ "error", "always" ] } };
I'm using Webpack with the following config:
I get the errors for "render" and the Button component on this file which is named Home.js:
From what I can tell in the docs I should be set up correctly. Is there something I'm missing?
The text was updated successfully, but these errors were encountered: