2 ms·
That's not really true. Regardless how many setters you have or invoke, state only changes between renders. Of course state is mutable, that's the whole point.
by bayesian_horse 5y ago
That's not really true. Regardless how many setters you have or invoke, state only changes between renders. Of course state is mutable, that's the whole point. It's not mutable during the render function though. It's also easier to accidentally mutate an object assigned to a const than a string or number.
Also, the setters are usually passed around all over the place, so no, I don't think the point is centralizing component state at all.
- nsonha 5y agocentralizing as in when you setState({ a: true }), you also think "wait a minute is having a `state.b` still makes sense, now that "a" is `true`", maybe it should be setState({ a: true, b: null }) > It's not mutable during the render function I don't think that's the point at all when people talk about mutability. To me mutability is just a proxy for "lacking access control", which again goes back to the point about centralizing state updates. So arguing about the technicality of what is mutable and what is not is pointless.