top | item 36069411 (no title) pjmq | 2 years ago To my eye, this makes vanilla JS more like React rather than making vanilla JS reactive. I'm basically looking for an even lighter Svelte if I can get it. Maybe this just isn't for me! discuss order hn newest pfg_|2 years ago If you just want to make vanilla js reactive, you can use solid js but without jsx (or something similar). This library could likely do the same. import { createRoot, createSignal, createRenderEffect } from "solid-js"; function SomeComponent() { const [count, setCount] = createSignal(0); const result = document.createElement("button"); createRenderEffect(() => result.textContent = "++ (" + count() + ")"); result.onclick = () => setCount(count() + 1); return result; } createRoot(cleanup => { const appv = document.getElementById("app"); appv.appendChild(SomeComponent()); });
pfg_|2 years ago If you just want to make vanilla js reactive, you can use solid js but without jsx (or something similar). This library could likely do the same. import { createRoot, createSignal, createRenderEffect } from "solid-js"; function SomeComponent() { const [count, setCount] = createSignal(0); const result = document.createElement("button"); createRenderEffect(() => result.textContent = "++ (" + count() + ")"); result.onclick = () => setCount(count() + 1); return result; } createRoot(cleanup => { const appv = document.getElementById("app"); appv.appendChild(SomeComponent()); });
pfg_|2 years ago