Skip to content
/ weeact Public

A wee, little, WIP React implementation for personal learning

License

Notifications You must be signed in to change notification settings

rencire/weeact

Repository files navigation

weeact

A wee little implemention of react.js for personal learning.

Quick start

Setup

Choose one of the following:

A) Nixos/Nix + Direnv (preferred):

If you're using nix, and have direnv installed (e.g. nix-env -i direnv), simply cd into this repo and the correct nodejs version will be installed.

B) NVM

If you have nvm, .nvmrc is provided.

C) None of above

Pick A or B.

Install:

npm install

Demo

An Example application is in index.html, and main.js.

npx browser-sync -s

Develop

Build src files

npx tsc --watch

Run tests on src changes

npx jest --watchAll

Run server and watch file for changes

npx browser-sync -s -f 'main.js' -f 'lib'

TODO

Vdom Syntax

  • Functional stateless component
  • Template for common DOM elements (h1, p, div)
  • Build virtual tree of components and dom nodes (initial render)
  • Initial render on page

Components

State

  • this.state in constructor
  • Hooks
    • assign setState hook to component
    • re-render component if state changes

Lifecycle methods

Rendering

This seems like the most complicated piece, depending on how performant we want to be. Currently we naively re-render the whole tree when any state changes.

  • Naively render all of virtual tree
  • Sub-tree Rendering
  • Batching renders

Diffing algorithm:

  • Elements:

    • different type
    • same type
  • Components:

    • different type
    • same type
  • Keys

  • Applying changes to DOM (maniuplate DOM directly, or just setInnerHTML?)

Misc

  • Event Delegation
  • Context API
  • ...Fiber?

Resources

React

typescript

Issues:

About

A wee, little, WIP React implementation for personal learning

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published