by aidenyb on 6/1/22, 12:34 AM with 88 comments
The idea is to have much faster rendering (a compiler optimizes virtual DOM beforehand) while ensuring the same developer experience React provides.
This is very, VERY early stage, so be prepared for weird bugs / plugin incompatibility / etc. If you have any suggestions, I'd be more than happy if you replied in a comment with it!
You can spin up the demo here >> https://stackblitz.com/github/aidenybai/million-react-compat
by bsimpson on 6/1/22, 1:34 AM
Considering the pretty docs, I'm guessing you're trying to get people to use this. It would be useful to have the value proposition front-and-center (e.g. in your README).
If someone is in the React mainstream, they use React. If they like the devex of React but want something simpler/more streamlined, they use Preact. I'd appreciate a "This is why you might choose this library instead of Preact. This is why this is a new library instead of a patch to Preact. This is an honest assessment of when React/Preact is a better choice than Million." section.
There are often tradeoffs in library development. Being honest about the ones you chose helps other developers trust you.
by a13n on 6/1/22, 12:55 PM
I feel like the main pain point with React is that routing, bundling, SSR, state management, etc. have to be painfully stapled together, and this is what frameworks like Next.js solve for.
by nick__m on 6/1/22, 3:31 AM
const [value, setValue] = useState(0);
should be: const [value, setValue] = useState(init);
or the parameter init could be removed from the component.by djbusby on 6/1/22, 1:51 AM
by sgb_QQ on 6/1/22, 3:00 PM
by Existenceblinks on 6/1/22, 6:08 AM
by mario_kart_snes on 6/1/22, 2:00 AM
by aidenyb on 6/1/22, 4:11 PM
Other than that, thank you so much for all the awesome feedback, it's really appreciated :)
by maxloh on 6/1/22, 8:32 AM
by spankalee on 6/1/22, 2:30 AM
Rather than creating and diffing a fine-grained tree of elements every render, it's very easy to use the syntactic structure of a template to see exactly what parts can and cannot change. To get stable and minimal DOM updates you just compare the template identity to the previously rendered template - if they match you update the dynamic expressions, if they don't you clear and render the new template.
This is what we did with lit-html and it's quite a bit faster (and smaller) than React and doesn't require a compiler because it uses standard JS tagged template literals. https://lit.dev/docs/libraries/standalone-templates/
It's a very simple approach and very, very hard to beat in the fast/small/simple/buildless tradeoff space. I hope one day that the DOM can include standard updatable DOM with a technique like this on top of the template instantiation proposal from Apple. It's such a common need that it should be built in.
by Existenceblinks on 6/1/22, 5:59 AM