React Mental Model Sketch
3th August 2023

Reactive Programming

Reactive Programming is a paradigm that deals with asynchronous data streams and the propagation of change. It's concerned with how a system reacts to changes over time and how these changes propagate through the system

React.js aligns with reactive programming concepts as follows

Mental Model Sketch for a React Component

React allows us to create Custom Components. We design the State, View Logic, Event Handlers, and Effect Logic for these Components. These Components can then act as building blocks and can be further composed hierarchically to form larger Components.


When a component instance is created, React monitors its State and mounts its Visual Component as specified by the View Logic. The Visual Component, characterized by its appearance and behavior, can transition between well-defined Visual States.


The user interacts with the Visual Component and experiences the Visual Component transitioning through different Visual States. These interactions may cause events and execution of corresponding event handlers. In addition to user-triggered events, other events may also activate handlers. The execution of these handlers can lead to updates in the Component’s State.


Upon State changes, React may initiate a Visual State Transition, specified by the re-execution of View Logic. After processing the state transition, React invokes Effect Logic for synchronization with external entities, commonly referred to as executing Side Effects. If updates occur during a given transition, React accumulates the updates and applies them after the transition is settled, leading to a new Transition Cycle and possibly a new Visual State. React uses a lot of optimization techniques during the transition cycles to prevent redundant Visual updates.