Demonstrating with a small peek under the hood how these highly anticipated functionalities will change the way people think about stateful components.
6. Why React Hooks?
● No more mixing Stateful and Stateless components
● Replacement for HoC and render props
● Facebook got it with almost zero effort with transition to Fiber
○ Fiber = Unit of work
○ Work prioritization
○ Virtual stack implementation
6
12. // Originally written by @jamiebuilds
let hooks = null;
export function useHook() {
hooks.push(hookData);
}
function reactInternalRenderAComponentMethod(component) {
hooks = [];
component();
let hooksForThisComponent = hooks;
hooks = null;
}
13
13. Is it really a rocket science?
https://github.com/tomkis/treact/pull/1/files
14