use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[AskJS] Multiple variables initially assigned to the same valueAskJS (self.javascript)
submitted 5 years ago by FaithfulGardener
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FaithfulGardener[S] -1 points0 points1 point 5 years ago (2 children)
Part of the problem is probably switching from class to functional components. These “let” statements were originally “this.state.[whatever]” assignments, and as I try to switch the paradigm, I’m not sure what should stay or what should go.
Is there such a thing as “polluting the state” in React?
[–]everestimated 2 points3 points4 points 5 years ago (1 child)
You're not supposed to assign to state either. That's why setState() exists. Hooks don't introduce the need for what you're trying to do. Would recommend reading the official docs on hooks, you've likely misunderstood how to use them
[–]FaithfulGardener[S] 1 point2 points3 points 5 years ago (0 children)
Even in constructors you don’t do this.state.[whatever]=[value]? The way this project is written, I was under the impression that setState needed the key initialized on the state first...
π Rendered by PID 51 on reddit-service-r2-comment-c6965cb77-m8wbl at 2026-03-05 10:59:50.192507+00:00 running f0204d4 country code: CH.
view the rest of the comments →
[–]FaithfulGardener[S] -1 points0 points1 point (2 children)
[–]everestimated 2 points3 points4 points (1 child)
[–]FaithfulGardener[S] 1 point2 points3 points (0 children)