Hacker News new | ask | show | jobs
by pjmq 1114 days 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!
1 comments

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());  
    });