loading...

re: Immutibilty: The anti-pattern? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I'm not sure I follow your argument. You first claim that people use immutability when they don't understand the complexities mutability brings. Th...
 

A very good point from my perspective on legibility. A key thing here is using stack based variables that have super low cost, so no point following my argument there. You can have many stack based variables without fearing a garbage collection glitch or a complex memory management operation.

So for clarity on my comment in light of this point, I'm suggesting that:

    something.state = {...something.state, x: something.state.x+1}

If you do it frequently is a bad idea for performance reasons due to the amount of memory being stored up for collection. It's also a bit less legible than:

   something.state.x += 1
code of conduct - report abuse