Shikhil Saxena

Jul 20, 2025 • 2 min read

🧠 React: A Formal Mental Model Rooted in Deterministic Design

React - A Minimal Mental Model Rooted in Reasoning

Modern UI frameworks often feel magical—but beneath React’s declarative syntax lies a precise philosophy shaped by functional programming and system design principles. This article is an exploration of React from first principles: how it mirrors the transformation, abstraction, and propagation patterns seen in data-oriented systems.

🔁 Transformation: UI as a Pure Function

At its core, React views UIs as pure projections of state. Just as a mathematical function transforms inputs into outputs deterministically, a React component transforms data into UI artifacts.

function NameBox(name) {

return { fontWeight: 'bold', labelContent: name };

}

This functional purity lays the foundation for reliable rendering and predictable updates. The UI isn’t merely a reflection of server logic—it’s a deterministic projection optimized for human interaction.

🧱 Abstraction: Reusable Encapsulation

UI construction begins with encapsulated units. These functions compose together like algebraic expressions, minimizing side effects and enabling reuse.

function FancyUserBox(user) {

return {

borderStyle: '1px solid blue',

childContent: [

'Name: ',

NameBox(user.firstName + ' ' + user.lastName)

]

};

}

This layering reflects a scalable data transformation pipeline, where each function abstracts complexity without leaking internals.

📦 Composition: Building Higher-Order Patterns

Composition takes abstraction a step further. Instead of just leaf-level reuse, we compose containers of containers, building higher-order functions that are semantically meaningful and reusable across stateful contexts.

function FancyBox(children) {

return {

borderStyle: '1px solid blue',

children: children

};

}

Composition enables semantic modularity—where higher-level systems emerge from low-level primitives, echoing patterns in microservices and monorepo structures.

🧠 State as Projection-Specific

React challenges the idea that UI state is a mirror of backend state. Instead, it treats state as specific to the projection instance—scroll position, transient form input, and interaction histories live within the UI's boundary, not the global state tree.

This leads to React’s top-down immutability model, threading update functions and state atoms through the rendering pipeline.

⚡️ Memoization: Optimization via Purity

With pure functions comes the opportunity for caching. Memoization transforms expensive recalculations into reference-based lookups, rooted in identity and immutability.

function memoize(fn) {

let cachedArg, cachedResult;

return function(arg) {

if (arg === cachedArg) return cachedResult;

cachedArg = arg;

cachedResult = fn(arg);

return cachedResult;

};

}

Memoization maps scale this pattern to lists, preserving performance across hierarchical UI trees.

🧩 Continuations: Decoupling Logic with Currying

As UIs become deeply nested, passing arguments directly grows cumbersome. React adopts currying and continuations, deferring execution and allowing for inversion of control.

function FancyUserList(users) {

return FancyBox(

UserList.bind(null, users)

);

}

This functional design mirrors async pipelines and event-driven architectures—where execution context is deferred and resolved based on system state.

🌱 Context as Algebraic Effects

React's context API behaves like algebraic effects—shortcuts to bypass intermediate layers. It allows non-linear data dependencies without violating purity.

function ThemeBorderColorRequest() {}

function FancyBox(children) {

const color = raise new ThemeBorderColorRequest();

return {

borderColor: color,

children

};

}

Context isn't just a feature—it's a formal expression of non-local dependency injection, akin to dependency graphs in complex systems.

🧮 React as a Compositional Runtime

What this mental model exposes is React’s nature as a runtime for composable, deterministic UIs. It isn't just a library—it’s a philosophy that:

  • Encourages data-driven design

  • Leverages composability over inheritance

  • Optimizes with functional purity and memoization

  • Adopts runtime-level abstractions for practical boilerplate reduction

Join Shikhil on Peerlist!

Join amazing folks like Shikhil and thousands of other builders on Peerlist.

peerlist.io/

It’s available... this username is available! 😃

Claim your username before it's too late!

This username is already taken, you’re a little late.😐

1

12

0