Mini React implementation made for fun and practice. Please do not use in production.
import { useState, createElement as c, render } from "./lib";
const Counter = () => {
const [count, setCount] = useState(0);
return c(
"div",
{},
c("div", {}, `Value: ${count}`),
c("button", { onClick: () => setCount(count + 1) })
);
};
render(c(Counter), document.getElementById("root"));
yarn start
to start the dev server at localhost:1234
.
yarn test
to see the tests passing.
- Accepting
style
object as alternative to string prop - Updater version of
setState
-
ref
s - Context API
-
<Fragment />
Blogged Answers: A (Mostly) Complete Guide to React Rendering Behavior
How Does setState Know What to Do?
The how and why on React’s usage of linked list in Fiber to walk the component’s tree
Inside Fiber: in-depth overview of the new reconciliation algorithm in React