JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11
  • Score
    100M100P100Q68713F
  • License MIT

🌞 A tiny React-like library built for learning React internals (Fiber, state, lifecycle).

Package Exports

  • sunny-react

Readme

🌞 SunnyReact

⚠️ Not production ready. Made for fun and understanding React internals.

A tiny React-like library built for learning React internals β€” Fiber, state, and lifecycle β€” but with a sunny twist β˜€οΈ.

πŸ‘‰ Perfect for developers who want to peek under the hood of React without drowning in complexity.


πŸš€ Install

npm install sunny-react

✨ Features

  • ⚑ Virtual UI (like Virtual DOM)
  • πŸͺ’ Fiber-like rendering with our "SunnyFiber"
  • πŸ”₯ Simple state management via UIUpdaterState
  • 🌱 Lifecycle hooks:
    • runOnlyOnce
    • runOnEachRender
    • runOnStateChange
  • βš™οΈ Works with JSX (via Vite + Babel pragma β†’ drawPiece)

πŸ“¦ Example Usage

Counter App

import {
  drawPiece,
  render,
  UIUpdaterState,
  runOnlyOnce,
  runOnEachRender,
  runOnStateChange
} from "sunny-react";

function SunnyCounter() {
  UIUpdaterState({
    count: 0,
    countUpdater: (val) => val
  });

  runOnlyOnce(() => console.log("Mounted 🌞"));
  runOnEachRender(() => console.log("Rendered πŸ”„"));
  runOnStateChange(([count]) => console.log("Count updated:", count));

  return (
    <div>
      <h1>Count = {count}</h1>
      <button onClick={() => countUpdater(count + 1)}>Increment</button>
      <button onClick={() => countUpdater(0)}>Reset</button>
    </div>
  );
}

const root = document.getElementById("root");
render(SunnyCounter, root);

⚑ Project Structure (when used with CSRA)

my-app/
β”œβ”€β”€ package.json
β”œβ”€β”€ vite.config.js
β”œβ”€β”€ index.html
└── src/
    β”œβ”€β”€ App.jsx
    β”œβ”€β”€ main.jsx
    └── global.css

πŸ› οΈ How It Works

SunnyReact replaces React’s jargon with funny but descriptive names:

  • drawPiece() β†’ like React.createElement()
  • Splitter β†’ breaks down work into small chunks (Fiber-ish)
  • Differentiator β†’ compares old vs new Virtual UI (diffing)
  • FinalToucher β†’ applies changes to real DOM

πŸ–ΌοΈ Demo

When scaffolded via create-sunny-react-app,
you’ll see a dark-themed intro page + working counter demo with lifecycle logs.


πŸ› οΈ Requirements

  • Node.js β‰₯ 16
  • npm β‰₯ 8

πŸ“œ License

MIT Β© 2025 Sunny Ghodeswar