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.


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?

  • 1
    Link to the issue?
  • 1
    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?
  • 1
    Excuse 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.
  • 0
    @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.
  • 1
    @Berkmann18 react docs literally say DO NOT MUTATE WHATEVER IS IN USESTATE
  • 0
    @kiki Good, I haven't used React much, nor I have read the docs since hooks were introduced, so I wasn't sure.
  • 2
    @kiki hehe Vue ftw
  • 0
    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
Add Comment