Reinventing React
April 13, 2022
In this article we are going to reverse-engineer parts of React from scratch as we build out a counter app. We will stay well under 100 lines of spacious code the whole time. We start with a counter app built with Web APIs and imperative commands, and slowly refactor our way to core React abstractions, ending in declarative functional components using hooks and JSX. Along the way, the reader will hopefully gain an intuitive understanding for why React looks the way it does, the logic behind some of React's design, and finally, understand why React is so popular, namely, that it represents a suite of improvements over the "vanilla" alternative of sequential, imperative Web API invocations, as we will see.