4 ms·
Nice handling of reactivity - I think this should already be in language as well. I'm not sure I like this single components approach and embedding JS in HTML.
by machiaweliczny 8y ago
Nice handling of reactivity - I think this should already be in language as well.
I'm not sure I like this single components approach and embedding JS in HTML.
The problem with this is that it's too frameworkish.
The big benefit of JSX/React rendering is that it's composable and declarative (as it's just functions), but it's also simple to get - render just returns wanted structure, given the state and you can use simple assert to verify that.
Solutions like angular/vue/svelte rely on custom template parsing which IMO sucks, because it's hard to extend/test without specific template compilers. JSX in contrast is embracing language.
I think that render functions written like in react and data reactivity is the simplest approach to describe application. Seems like VueJS with JSX is closest to this right now.
It would be cool to keep similar API but maybe use compiling to have smaller bundle/older browsers support/different platform support etc.
To be clear by similar API I mean just pure JSX components, where you plugin reactive data, that could be tested without any frameworks and without rendering. This is the simplest way, yet nobody build it yet - MobX + pure React components is close to this (problem is that still rendering is done by React, so rendering isn't most performant - depends on components hierarchy) - with compilation/integration you could make it more performant, but I would keep declararive nature and simplicity of JSX.
- lhorie 8y ago> it's hard to extend This is actually a feature, considering what Svelte does. I know of more than a few efforts to implement similar compile-time production of low level procedural code from React components, but so far nobody's been quite able to do it. And this is despite these efforts coming from some very smart people. The reason this is so hard to do for React is precisely because Javascript is a huge target with a ton of bizarre quirks and edge cases. > To be clear by similar API I mean just pure JSX components, where you plugin reactive data, I think Solid.js is the closest thing to this atm. Not React-based though.
- jadbox 8y agoMobx-state-tree is a really nice balance of state management that also is compatible with all the nice Redux browser tools https://github.com/mobxjs/mobx-state-tree https://github.com/mobxjs/mobx-state-tree
- nickdandakis 8y agoSvelte exposes a [preprocess function](https://svelte.dev/docs#svelte_preprocess https://svelte.dev/docs#svelte_preprocess) that (in theory?) you could use to preprocess markup JSX-style.
- ryansolid 7y agoCheck out my library DOM Expressions(https://github.com/ryansolid/dom-expressions#readme https://github.com/ryansolid/dom-expressions#readme) It's almost exactly what you are talking about. The libraries I've written on top (Solid.js, MobX JSX, and KO JSX) are among the fastest on the JS Frameworks Benchmark(https://krausest.github.io/js-framework-benchmark/current.html https://krausest.github.io/js-framework-benchmark/current.ht...). The future is already here.