MCPcopy Index your code
hub / github.com/RobPruzan/react-scratch

github.com/RobPruzan/react-scratch @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
77 symbols 118 edges 5 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

This codebase attempts to implement React, including:

  • internal view hierarchy + reconciliation
  • application of view hierarchy to dom
  • a subset of hooks (useState, useEffect, useContext, useMemo, useCallback, useRef)

While adhering to the existing API and external behavior:

  • Same render behaviors
  • Same API (other than minor differences that weren't important to implement)

If you are interested in how this was developed, I made an article going through the internal architecture: https://www.rob.directory/blog/react-from-scratch

To run the project for development:

bun run react
bun run dev

This will compile all the TS code in src/, which then a bun server will serve a website at http://localhost:3000

The demo website is supposed to be an example of all the different features implemented. It includes

  • Rendering components as children
  • Hooks
  • useState
  • useMemo
  • useCallback
  • useContext
  • useRef
  • Fetching data
  • Conditional components
  • Rendering components in lists, with removing + adding items
  • Optimized DOM updates

Screen-2024-08-23-182000-ezgif com-optimize

Core symbols most depended-on inside this repo

aux
called by 9
src/react/core.ts
findFirstTagNode
called by 6
src/react/core.ts
getComponentName
called by 4
src/react/core.ts
findRenderNodeOrThrow
called by 3
src/react/core.ts
reRenderChild
called by 3
src/react/core.ts
aux
called by 2
src/utils.ts
updateElement
called by 2
src/react/core.ts
updateDom
called by 2
src/react/core.ts

Shape

Function 77

Languages

TypeScript100%

Modules by API surface

src/react/core.ts36 symbols
src/script.ts33 symbols
src/utils.ts8 symbols

For agents

$ claude mcp add react-scratch \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page