5 ms·
NueJS: “It’s just HTML!” The HTML: <button @click=“count++”> {count} </button>
by qabqabaca 3y ago
NueJS: “It’s just HTML!”
The HTML: <button @click=“count++”> {count} </button>
- tipiirai 3y agoPlease read the whole sentence. It starts with: If React is “Just JavaScript, then...” React users often say that "It's just JavaScript" but then they write: return ( <div> <h2>You clicked {count} times!</h2> <button onClick={() => setCount(count - 1)}> Decrement </button> <button onClick={() => setCount(count + 1)}> Increment </button> </div> ) Nue is the opposite side of the same coin.
- _v7gu 3y agoisn't that just syntax sugar? I believe it compiles into (for some el function and safe string tag) return el("div", { children: [ el("h2", { children: [safe`You clicked ${count} times!`]) }, el("button", { onClick: () => setCount(count - 1), children: [safe`Decrement`] }), el("button", { onClick: () => setCount(count + 1), children: [safe`Increment`] }) ]}); The "it's just javascript" part comes from having no hidden getters, setters or proxies littered in code that may or may not behave as how we expect, and not littering the html with react-specific attributes for iteration, events, etc
- tipiirai 3y agoIt surely is. React is a good pick for frontend engineers who prefer to use JavaScript or TypeScript. Nue is designed for UX engineers, who prefer a HTML- like syntax for defining the structure & layout.
- qabqabaca 3y agoDo people generally say React is “just JavaScript”? I’ve seen it said about Svelte, never React. In any case, why market your framework with an equally poor comparison?
- sattoshi 3y agoYes people say that, and it is 100% true. You can use all React features without any special tooling.
- paulddraper 3y ago> If React is “Just JavaScript, then...” React is just JavaScript. React+JSX is JSX. This: <button onClick={() => setCount(count + 1)}>{count}</button> Is sugar for: React.createElement('button', { onClick: () => setCount(count + 1) }, count) True, the JSX version is most popular, but it's trivial syntax sugar with no "magic." This is different then Angular, Vue, Svelte, etc templates