Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Generally speaking because I don't know what the story is. Isn't it a reacty rule to just set the state again if it changes rather than mutate it directly?
-
kiki351874yExcuse me but you shouldn’t mutate whatever stored in useState. React has no fucking way to know if it was mutated or not, it’s not Vue.
-
@kiki Even Vue has restrictions in how you can mutate stuff, and the docs are pretty clear on that (not sure that can be said of React).
Seems like the person the OP is on about simply lacks understanding of state changes and what (not) to do. -
@kiki Good, I haven't used React much, nor I have read the docs since hooks were introduced, so I wasn't sure.
-
What's bluntly obvious is you're reporting expected behaviour as a bug. They're not going to fundamentally change their api because you don't like the way it's designed
-
normanzb473y@M3m35terJ05h how can that be blunt if you are using somebody else's hook which changed the internal of state object, and 90% of the time it works without problem, and 10% of the time react moans about it by behaving weirdly in some the other places that has nothing todo with the place where you used the hook?
React's `useEffect()` won't fire if you have someone in your team wrote a hook that maintain a state of an array, mutates the array, empties it, and then set it back to the state.
https://codesandbox.io/s/...
Reported it, ticket closed without asking, told should avoid mutating the object stored in useState.
Isn't it bluntly obvious that if someone spent hours to spot the line in hundreds of lines of code, which actually caused the problem and reduce the whole piece of turds into some understandable minimal reproducible example means they must of course for sure know that by avoiding mutating the array it will fix the bloody issue?
Isn't that bluntly obvious they are trying to say that there is a bigger issue behind those twisted wires?
rant