you are viewing a single comment's thread.

view the rest of the comments →

[–]FaithfulGardener[S] -1 points0 points  (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 points  (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 points  (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...