React like reactivity demo (with hooks)
Basic demo of how to implement a very basic version of how React hooks work.
Click on the page to increase the counter, or type in the input box to set a name.
There are of course an almost endless list of things that are not implemented here. Its just a demo of a very
basic view of how state / hooks work in React. It should also clear up any confusion why you have to use
state/hooks before any conditionals in components.
I've only implemented the following:
- a basic render function (that supports rendering one component, no child components)
- useState which works in a simplified way to React's useState
- useEffect which works in a simplified way to React's useEffect. In the demo when you click the page, only one useEffect call is run (the one with a dependency of the click count).
- Updating of the DOM is done in an imperative way
- It re-renders every 100ms, not only when state changes. This is a demo of how the hooks/state work, and not
how react renders
- and a million other things