JavaScript and React course Β· Module 1: React Basics

History and philosophy of React

3 min read Β·
In this lesson2

Our journey with React began in the offices of Facebook (now Meta) in 2011. Jordan Walke, an engineer working for the company, created an early version of React, inspired by functional aspects of programming and the problems developers faced when building complex user interfaces.

Facebook initially used React internally for its News Feed, but the real breakthrough came in 2013 when they decided to release the library as an open-source project. That was the moment when React began its journey to the stars, becoming one of the most popular libraries for building user interfaces in the world.

React's Philosophy

React's philosophy is based on several revolutionary concepts:

  1. Declarativeness - React allows you to describe how the interface should look in a given state, rather than imperatively specifying how to change it. It's like the difference between saying "draw me a star with five arms" (declaratively) and "draw a line at 72 degrees, then at 144 degrees..." (imperatively).

  2. Component-based architecture - An application is built from independent, reusable components, similar to how a spaceship is composed of modules that can be manufactured, tested, and improved independently. Every button, panel, and form can be a separate component that connects with others to create a cohesive whole.

  3. Unidirectional data flow - Data flows from top to bottom (from parent to child), making it easier to understand how data moves through the application. Imagine a cascade - water always flows from top to bottom, never in reverse. This predictability makes applications more stable and easier to debug.

  4. "Think about the user" - React encourages creating interfaces that are intuitive and user-friendly. This is a fundamental change compared to earlier approaches where technology often dictated the user experience.

History of React's development

React has undergone a fascinating evolution since its first public release:

2013: First release

  • Introduction of the component architecture concept
  • Implementation of Virtual DOM
  • Initial support for JSX

2015: React Native

  • Extending React's philosophy to mobile applications
  • The same syntax and similar concepts for building native mobile apps

2016: React 15

  • Significant performance improvements
  • Better error and warning messages

2017: React 16 (Fiber)

  • Complete rebuild of the reconciliation algorithm
  • Introduction of fragments, portals, and error handling
  • Better support for asynchronous rendering

2019: React 16.8 (Hooks)

  • Revolutionary change in state and side effect management
  • Enabling the use of state and other React features without writing classes
  • Significant simplification of code and logic

2020-2022: React 17 and 18

  • New JSX transform (React 17) - importing React in JSX files is no longer needed
  • Concurrent rendering and createRoot (React 18)
  • Automatic update batching
  • Suspense in server-side rendering too

2024: React 19

  • Stable Server Components and Actions
  • Removal of deprecated APIs, including ReactDOM.render

This evolution shows how React has consistently developed to meet the challenges of modern web application development, always focusing on improving the experience for both developers and end users.

Code for this lesson: App.jsx
import React from 'react';

// Timeline component for presenting React history
function TimelineEvent({ year, title, description, isImportant }) {
  return (
    <div style={{
      display: 'flex',
      marginBottom: '20px',
      alignItems: 'flex-start'
    }}>
      <div style={{
        minWidth: '80px',
        textAlign: 'right',
        marginRight: '20px'
      }}>
        <div style={{
          backgroundColor: isImportant ? '#ff5722' : '#2196f3',
          color: 'white',
          padding: '5px 10px',
          borderRadius: '15px',
          fontSize: '14px',
          fontWeight: 'bold'
        }}>
          {year}
        </div>
      </div>
      <div style={{
        flex: 1,
        padding: '15px',
        backgroundColor: isImportant ? '#fff3e0' : '#e3f2fd',
        borderRadius: '8px',
        borderLeft: `4px solid ${isImportant ? '#ff5722' : '#2196f3'}`
      }}>
        <h3 style={{
          margin: '0 0 10px 0',
          color: isImportant ? '#e65100' : '#1565c0'
        }}>
          {title}
        </h3>
        <p style={{ margin: 0, lineHeight: '1.5' }}>
          {description}
        </p>
      </div>
    </div>
  );
}

// Component for presenting React philosophy
function PhilosophyCard({ icon, title, description }) {
  return (
    <div style={{
      backgroundColor: '#f8f9fa',
      border: '1px solid #dee2e6',
      borderRadius: '8px',
      padding: '20px',
      textAlign: 'center',
      transition: 'transform 0.2s',
      cursor: 'pointer'
    }}
    onMouseEnter={(e) => e.target.style.transform = 'translateY(-5px)'}
    onMouseLeave={(e) => e.target.style.transform = 'translateY(0)'}
    >
      <div style={{ fontSize: '48px', marginBottom: '15px' }}>{icon}</div>
      <h3 style={{ color: '#343a40', marginBottom: '10px' }}>{title}</h3>
      <p style={{ color: '#6c757d', lineHeight: '1.5' }}>{description}</p>
    </div>
  );
}

// Interactive component demonstrating declarativeness
function DeclarativeExample() {
  const [isVisible, setIsVisible] = React.useState(true);
  const [items, setItems] = React.useState(['Element 1', 'Element 2', 'Element 3']);

  const addItem = () => {
    const newItem = `Element ${items.length + 1}`;
    setItems([...items, newItem]);
  };

  const removeItem = () => {
    setItems(items.slice(0, -1));
  };

  return (
    <div style={{
      backgroundColor: '#e8f5e8',
      padding: '20px',
      borderRadius: '8px',
      margin: '20px 0'
    }}>
      <h3 style={{ color: '#2e7d32' }}>Declarative React in Action</h3>

      <div style={{ marginBottom: '20px' }}>
        <button
          onClick={() => setIsVisible(!isVisible)}
          style={{
            padding: '10px 15px',
            margin: '5px',
            backgroundColor: '#4caf50',
            color: 'white',
            border: 'none',
            borderRadius: '4px',
            cursor: 'pointer'
          }}
        >
          {isVisible ? 'Hide' : 'Show'} List
        </button>

        <button
          onClick={addItem}
          style={{
            padding: '10px 15px',
            margin: '5px',
            backgroundColor: '#2196f3',
            color: 'white',
            border: 'none',
            borderRadius: '4px',
            cursor: 'pointer'
          }}
        >
          Add Item
        </button>

        <button
          onClick={removeItem}
          disabled={items.length === 0}
          style={{
            padding: '10px 15px',
            margin: '5px',
            backgroundColor: items.length === 0 ? '#ccc' : '#f44336',
            color: 'white',
            border: 'none',
            borderRadius: '4px',
            cursor: items.length === 0 ? 'not-allowed' : 'pointer'
          }}
        >
          Remove Item
        </button>
      </div>

      {isVisible && (
        <ul style={{
          backgroundColor: 'white',
          padding: '15px',
          borderRadius: '4px',
          listStyle: 'none'
        }}>
          {items.map((item, index) => (
            <li key={index} style={{
              padding: '8px',
              margin: '5px 0',
              backgroundColor: '#f0f0f0',
              borderRadius: '4px'
            }}>
              {item}
            </li>
          ))}
          {items.length === 0 && (
            <li style={{
              padding: '20px',
              textAlign: 'center',
              color: '#666',
              fontStyle: 'italic'
            }}>
              The list is empty
            </li>
          )}
        </ul>
      )}

      <p style={{
        marginTop: '15px',
        fontSize: '14px',
        color: '#666',
        fontStyle: 'italic'
      }}>
        Notice how declaratively we describe the UI: "if isVisible is true, show the list"
      </p>
    </div>
  );
}

export default function App() {
  return (
    <div style={{
      fontFamily: 'Arial, sans-serif',
      maxWidth: '900px',
      margin: '0 auto',
      padding: '20px'
    }}>
      <header style={{
        textAlign: 'center',
        marginBottom: '40px',
        padding: '30px',
        background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
        color: 'white',
        borderRadius: '12px'
      }}>
        <h1 style={{ margin: '0 0 10px 0', fontSize: '2.5rem' }}>History of React</h1>
        <p style={{ margin: 0, fontSize: '1.1rem', opacity: 0.9 }}>
          A journey through the evolution of the most popular JavaScript library
        </p>
      </header>

      <section style={{ marginBottom: '40px' }}>
        <h2 style={{ color: '#333', borderBottom: '2px solid #667eea', paddingBottom: '10px' }}>
          Key Moments in React History
        </h2>

        <TimelineEvent
          year="2011"
          title="Birth of FaxJS"
          description="Jordan Walke at Facebook creates an early version of React (then called FaxJS) inspired by XHP - a PHP component system."
        />

        <TimelineEvent
          year="2013"
          title="React Goes Open Source!"
          description="Facebook releases React as an open source project. Tom Occhino and Jordan Walke present it at JSConf US."
          isImportant={true}
        />

        <TimelineEvent
          year="2015"
          title="React Native"
          description="Facebook introduces React Native, allowing developers to use React to build native mobile applications."
          isImportant={true}
        />

        <TimelineEvent
          year="2017"
          title="React Fiber"
          description="Complete rewrite of the React core (React 16) introducing a new reconciliation architecture called Fiber."
          isImportant={true}
        />

        <TimelineEvent
          year="2019"
          title="React Hooks"
          description="React 16.8 introduces Hooks, revolutionizing the way React components are written and state is managed."
          isImportant={true}
        />

        <TimelineEvent
          year="2022"
          title="React 18"
          description="Introduction of Concurrent Features, Automatic Batching, Suspense improvements and new hooks."
        />

        <TimelineEvent
          year="2024"
          title="React 19"
          description="Stable Server Components and Actions; removal of deprecated APIs such as ReactDOM.render."
          isImportant={true}
        />
      </section>

      <section style={{ marginBottom: '40px' }}>
        <h2 style={{ color: '#333', borderBottom: '2px solid #667eea', paddingBottom: '10px' }}>
          React Philosophy
        </h2>

        <div style={{
          display: 'grid',
          gridTemplateColumns: 'repeat(auto-fit, minmax(250px, 1fr))',
          gap: '20px',
          margin: '20px 0'
        }}>
          <PhilosophyCard
            icon="β—†"
            title="Declarativeness"
            description="You describe WHAT the UI should look like in a given state, not WHAT steps to take to achieve it."
          />

          <PhilosophyCard
            icon="β—†"
            title="Composability"
            description="The application consists of independent, reusable components that can be composed together."
          />

          <PhilosophyCard
            icon="β–Ό"
            title="Unidirectional Flow"
            description="Data flows from top to bottom, making the application predictable and easy to debug."
          />

          <PhilosophyCard
            icon="β—†"
            title="Learn Once, Write Anywhere"
            description="The same concepts work on web, mobile (React Native) and desktop."
          />
        </div>
      </section>

      <DeclarativeExample />

      <footer style={{
        backgroundColor: '#f8f9fa',
        padding: '20px',
        borderRadius: '8px',
        textAlign: 'center',
        marginTop: '40px'
      }}>
        <h3 style={{ color: '#495057' }}>React Today</h3>
        <p style={{ color: '#6c757d', lineHeight: '1.6' }}>
          React is used by millions of developers worldwide in companies such as
          Facebook, Netflix, Airbnb, Uber, WhatsApp, Instagram and thousands of others.
          Its ecosystem includes thousands of libraries and tools, making it one of the
          most powerful platforms for building modern web applications.
        </p>
      </footer>
    </div>
  );
}

Spotted a mistake in this lesson?

  1. Project to submitProject: Space Station React Control Panel
  2. VideoVideo: Module Summary

Useful articles