Show HN: React without the magical anti-patterns
loreanvictor.github.io
loreanvictor.github.io
- The library doesn't do much. There is no VDOM, DOM reconciliation, etc. Its a JSX-compliant wrapper for DOM APIs, that also supports reactive elements.
- The library is extremely predictable. A component is just a function. It will be called exactly once, when you call it (i.e. when you write <MyComponent/>). You can "use state" anywhere in the code, not just in "Components". There are no weird rules (such as React's hook rules).
- The end result is surprisingly similar to React in style and convenience. That said, some stuff get more explicit. Where in React you would write `{x + y}`, here you need to write `{expr($ => $(x) + $(y))}` because `x` and `y` are now explicitly reactive literals and not plain JS variables.
- Bonus for those who like reactive programming: you can use transforms (such as debounce, throttle, flattening, etc) easily on your states, as all of this comes from an independent specification for reactive literals (callbags specification).
- Also bonus: Since it doesn't do much, Callbag-JSX doesn't have much code and so is faster and more light-weight than Angular or React. That said, if performance is your primary concern, there are other options out there.
As for components: you are correct, there are no examples of components on the first page. There is one in "Getting Started", but that is a pretty simple one with the state defined outside of the component. That said, "components" in Callbag-JSX are just functions, "stateful components" are functions with closure. Though perhaps I should elaborate on that further.