Live data from Hacker News

VanJS – A no-JSX framework based on vanilla JavaScript

vanjs.org

91–100 of 178 posts

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#91
post #88
post #78

Earlier quoted context omitted.

challenge accepted (app #2, since #1 is just static), BEHOLD: const Counter = () => { let counter = 0; const updCounter = (delta) => { counter += delta; document.getElementById('count').innerText = `♥ ${counter}`; }; document.getElementById('up').addEventListener('click', () => updCounter(1)); document.getElementById('down').addEventListener('click', () => updCounter(-1)); updCounter(0); }; Counter(); *thumbs-up* *th…

Elements with an id are globals, so you do this (not that it's recommended): count.innerText = up.onclick = down.onclick = etc

Technically, every element that's not in the shadow DOM is a global. But yes, there's plenty of ways to implement this and an argument to had for most of them.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#92
post #90

The library looks nice dx wise but complete lack of any lifecycle hooks is a bummer. I get that minimalism is the core theme but to use any js ui lib that is not explicitly built around the same reactivity model you need to hook into component lifecycle.

Life-cycle hooks typically run as side-effects from state changes, so that would be your route to do something similar.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#93

This is where most libraries are going. Svelte 5 builds upon these signals / derivations as well, and I guess a bunch of other libraries. It would be time for them to get together and standardize on a signals library at this point that could be adopted to be a web standard and help interoperability between web components built with different frameworks.

MobX and chill. Works with React, Vue, Solid, and etc.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#98

Earlier quoted context omitted.

Is this the main argument? I think the simplest answer is boundaries. Taking into account how much nesting is involved in writing HTML, it's a clear benefit having a named boundary vs a closing parenthesis.

> Taking into account how much nesting is involved in writing HTML which is another one of its flaws.

What would the alternative be? How can you design a UI without nesting things?

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#99
post #87

I don’t know why they’re selling lack of JSX as a feature. React works without JSX too. It’s just (very convenient) syntactic sugar.

It is really an odd flex. As soon as you need a transpiler, which many modern JS devs are going to want and need for the benefits they provide (Typescript being huge) then using JSX seems a benefit not a problem to solve.

Re: VanJS – A no-JSX framework based on vanilla JavaScript

#100

Earlier quoted context omitted.

Agreed. JSX is a bug, not a feature.

... and imposes a build step, for no good reason.

The preact team also dislikes transpiling jsx so they've developed an alternative using tagged template literals: https://github.com/developit/htm
Post reply on HN