What's wrong with React, and how MDG can fix it IMHO

…it seems to me that they don’t even need to be “stateful”. The framework (React) can handle all the side-effects of binding everything together and passing your functions everything you need–just like side effects is addressed in Elm with monads or (monadic-like solutions) and like Redux seems to address with “middleware”. So for example we could remove this before handleClick here:

export function render(props, state) {
  return (
    <div>
      Clicked {state.count} times
      <button onClick={handleClick} style={{ width: props.width }} />
    </div>
  );
}

The platform passes in state instead and ideally gets it from a single source of truth atom, thereby removing the requirement that components maintain any of their own state. Or, simply passes it in as props just as Redux does via “higher order components”–and for event handlers passes in the global state atom in addition to the props of the corresponding component.

…actually I’m gonna create a new post that covers this in depth here:

5 Likes