Assigned a Value but Never Used | No Unused Vars | React JS Debugging | Eslint Warnings & Errors

Published: 01 January 1970
on channel: WebStylePress
41,249
146

In react component I want to display a name but I want to read it from the app state. This name will not be changed but it can pass along to multiple components down the line. I used useState hook to implement state in react app. When I run this app, it gives me warning in console, in visual studio output window and when I hover over setName variable, I see same warning message.

setName is declared but its value is never read. setName is assigned a value but never used, eslint, no unused vars. This warning is related to eslint code linter. eslint helps me write better code and checks errors and warnings, it lets me know about the error or warnings before code runs. State is being used in react app but it will not change so setState is useless here and we can safely remove that.

Warning is gone when I removed the setName. The app is working fine. So remove variables that are not being used in your app.

Thank You!
👍 LIKE VIDEO
👊 SUBSCRIBE
🔔 PRESS BELL ICON
✍️ COMMENT

Channel:    / webstylepress  
Website: https://www.webstylepress.com
FaceBook:   / webstylepress  
Twitter:   / webstylepress  
GitHub: https://github.com/webstylepress
#react #debugging #eslint #js #reactjs #javascript #webstylepress #webdevelopment #linting


Watch video Assigned a Value but Never Used | No Unused Vars | React JS Debugging | Eslint Warnings & Errors online without registration, duration hours minute second in high quality. This video was added by user WebStylePress 01 January 1970, don't forget to share it with your friends and acquaintances, it has been viewed on our site 41,249 once and liked it 146 people.