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
On this page of the site you can watch the video online Assigned a Value but Never Used | No Unused Vars | React JS Debugging | Eslint Warnings & Errors with a duration of hours minute second in good quality, which was uploaded by the user WebStylePress 01 January 1970, share the link with friends and acquaintances, this video has already been watched 41,249 times on youtube and it was liked by 146 viewers. Enjoy your viewing!