Earlier quoted context omitted.
If you're worried about an extra network round-trip, section of your document.
Frameworks need product code.
VanJS – A no-JSX framework based on vanilla JavaScript
171–178 of 178 posts
Re: VanJS – A no-JSX framework based on vanilla JavaScript
#172Earlier 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.
Re: VanJS – A no-JSX framework based on vanilla JavaScript
#173Earlier 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/
Re: VanJS – A no-JSX framework based on vanilla JavaScript
#174Earlier 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/
Re: VanJS – A no-JSX framework based on vanilla JavaScript
#175Re: VanJS – A no-JSX framework based on vanilla JavaScript
#176Earlier 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…
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
#177Re: VanJS – A no-JSX framework based on vanilla JavaScript
#178The 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.