Live data from Hacker News

VanJS – A no-JSX framework based on vanilla JavaScript

vanjs.org

171–178 of 178 posts

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

#171
post #107

Earlier quoted context omitted.

If you're worried about an extra network round-trip, section of your document.

Frameworks need product code.

With bundler like esbuild, all JS code, including 3rd party libraries can be bundled into a single file. You don't need an extra round trip for a library.

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

#172
post #169

Earlier quoted context omitted.

Would we expect the list to re-render once the fetch finishes? This may just be years of react poisoning my brain const Stargazers = () => { const stargazers = van.state([]); fetch(`https://api.github.com/repos/vanjs-org/van/stargazers?per_page=5`) .then((r) => r.json()) .then((r) => stargazers.val = r); return ul( stargazers.val.map((s) => li(s.login)) ); };

Yes. This is how VanJS works. Code with VanJS is often more concise compared to equivalent code with React.

Ah ok! Very cool. Maybe I'm still missing a tiny piece of syntax? I don't see any output when I run that code in the fiddle

https://jsfiddle.net/397fb684/

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

#173
post #169

Earlier quoted context omitted.

Yes. This is how VanJS works. Code with VanJS is often more concise compared to equivalent code with React.

Ah ok! Very cool. Maybe I'm still missing a tiny piece of syntax? I don't see any output when I run that code in the fiddle https://jsfiddle.net/397fb684/

Ah.. you need a binding function to wrap the state-derived content into a reactive UI element, see: https://vanjs.org/tutorial#state-derived-child. I made the change in your code to make it work: https://jsfiddle.net/rkfmpx06/1/

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

#174
post #173

Earlier quoted context omitted.

Ah ok! Very cool. Maybe I'm still missing a tiny piece of syntax? I don't see any output when I run that code in the fiddle https://jsfiddle.net/397fb684/

Ah.. you need a binding function to wrap the state-derived content into a reactive UI element, see: https://vanjs.org/tutorial#state-derived-child . I made the change in your code to make it work: https://jsfiddle.net/rkfmpx06/1/

Oh! I understand, thanks for walking through that. Yes very terse compared to the equivalent react :)

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

#176
post #170

Earlier quoted context omitted.

I don't get you. Could you elaborate?

In the example I linked, the VanJS state cannot contain an element reference. This would lead to unexpected results. So you have to be careful with state management, regardless of whether it's automated or not. There are similar pitfalls, including performance issues, with any state management system, hence dedicated state management solutions like Redux exist to address this. The core of the argument is that complex…

Tbh I can't follow your logic here. You mentioned that in VanJS there are things that need to be careful with. But the same is true for other frameworks, even for plain Vanilla JavaScript. Thus what exactly the point that you're trying to make?

Complexity can't be avoided for extremely complex use cases. But that doesn't mean a simple solution that can work for most of the use cases has no value.

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

#178
post #115

The author seems to be chasing the small size trophy at any cost...to the point where he's using "var" instead of "const" because it saves a few bytes. Not indicative of someone serious...

No offense. What exactly is the cost of using "var" instead of "const"? You seem to pretend it to be a big deal.

It sacrifices maintainability and robustness to save a measly 80 bytes (I counted).
Post reply on HN