ReginaTheMean
ReginaTheMean

Reputation: 67

Remove unused conponents from ReactJS project

I have a React application, and a bunch of no-unused-vars in the console when running it getting me nuts, so I'm kindly asking you folks to share your experience: are there any such tools or no.

Screenshot of the console: enter image description here

Upvotes: 2

Views: 7239

Answers (2)

TOBE
TOBE

Reputation: 122

When projects get large its a pain to manage old code, what I did is to write a script to find unused exports (these will not be picked up by eslint) it should show you where you have a export that is not imported anywhere

just run:

npx dead-exports

assuming that your code is in ./src

read more here:

https://www.npmjs.com/package/dead-exports

Upvotes: 7

Vipul Sharma
Vipul Sharma

Reputation: 21

Use vs code with and ES7 React/Redux/GraphQL/React-Native snippets proper code formatter like prettier and you will find unused components in different color as compared to used component

Upvotes: 0

Related Questions