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
Nesta página do site você pode assistir ao vídeo on-line Assigned a Value but Never Used | No Unused Vars | React JS Debugging | Eslint Warnings & Errors duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário WebStylePress 01 Janeiro 1970, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 41,249 vezes e gostou 146 espectadores. Boa visualização!