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:
runOnlyOncerunOnEachRenderrunOnStateChange
- βοΈ 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()β likeReact.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