A simplified MVP version of React - demonstrating core component-based rendering with JSX
This project is a minimal implementation of React's core concepts, built to understand and demonstrate:
- Component-Based Architecture: Build encapsulated components that manage their own rendering
- JSX Support: Write HTML-like syntax in JavaScript, transformed via Babel
- Virtual DOM: Create lightweight JavaScript representations of UI elements
- Declarative Rendering: Describe what the UI should look like, not how to build it
✅ JSX Transformation - Uses Babel to transform JSX syntax into JavaScript function calls
✅ createElement API - Creates virtual DOM elements similar to React
✅ render Function - Converts virtual DOM to real DOM elements
✅ Component Class - Base class for building components (simplified)
✅ No External Dependencies - Pure implementation using standard build tools
# Clone the repository
git clone https://github.com/gitmvp-com/simple-react-mvp.git
cd simple-react-mvp
# Install dependencies
npm install
# Build the library
npm run build
# Serve the example
npm run serveThen open http://localhost:3000/example/ in your browser.
Babel transforms JSX into createElement calls:
// JSX syntax
const element = <div>Hello World</div>;
// Transforms to:
const element = SimpleReact.createElement('div', null, 'Hello World');The createElement function creates a virtual DOM object:
{
type: 'div',
props: {},
children: [
{ type: 'TEXT_ELEMENT', props: { nodeValue: 'Hello World' }, children: [] }
]
}The render function converts the virtual DOM to real DOM elements:
SimpleReact.render(element, document.getElementById('root'));Creates a virtual DOM element.
- type: String (HTML tag) or Component class
- props: Object of properties/attributes
- children: Child elements or text
Renders a virtual DOM element to a real DOM container.
- element: Virtual DOM element created by
createElement - container: Real DOM node to render into
Base class for creating components (simplified version).
simple-react-mvp/
├── src/
│ └── index.js # Core SimpleReact implementation
├── example/
│ └── index.html # Demo application
├── dist/
│ └── simple-react.js # Built bundle
├── package.json # Dependencies (matching React's versions)
├── rollup.config.js # Rollup bundler configuration
├── babel.config.js # Babel configuration for JSX
└── README.md
This MVP focuses on core concepts and intentionally omits:
- ❌ Hooks (useState, useEffect, etc.)
- ❌ Advanced reconciliation/diffing algorithm
- ❌ Fiber architecture
- ❌ Event system
- ❌ State management and re-rendering
- ❌ Context API
- ❌ Suspense and lazy loading
- ❌ Server-side rendering
This project uses the same build tools and versions as React:
- Babel: ^7.11.1 (JSX transformation)
- Rollup: ^3.29.5 (Module bundling)
- @babel/plugin-transform-react-jsx: ^7.23.4 (JSX plugin)
To understand more about React's internals:
MIT License - feel free to use this for learning and experimentation!
Inspired by React by Facebook. This is an educational project to demonstrate React's core concepts in a simplified form.