4
lorentz
3y

Why on Earth is React.Component.state public? This doesn't make any sense. It has no significance, but it just feels so, so stupid.

Comments
  • 4
    Because react's public interface is an imperative trash fire masquerading as a declarative, functional system.

    Re react source:
    /** * Sets a subset of the state. Always use this to mutate * state. You should treat `this.state` as immutable.

    * * There is no guarantee that `this.state` will be immediately updated, so * accessing `this.state` after calling this method may return the old value.
    * * There is no guarantee that calls to `setState` will run synchronously, * as they may eventually be batched together. You can provide an optional * callback that will be executed when the call to setState is actually * completed. *
  • 0
    @SortOfTested I agree, but at least the traps are properly documented. I'm a bit impressed.
Add Comment