Front End Web Developer
18 yo trying to make sense of this crazy world. I love playing around with Svelte and different APIs . Going through #100daysofcode
Markdown supported · ⌘↵ to post
Great read. It has everything I expected to see when I opened the article. Very well written Ameen
Keep up the good work.
René Monroy
I like Svelte but that code comparison is kinda staged. A fair one would use hooks on React, also would properly clear the interval in Svelte too and used the component created inside other component as well.
For React can be done this way (and clearing the interval):
function Timer() { const [seconds, setSeconds] = useState(0); useEffect(() => { const interval = setInterval(() => { setSeconds(seconds + 1); }, 1000); return () => clearInterval(interval); }); return <span>Seconds: {seconds}</span>; }Either way, Svelte is really nice and I'd recommend it every day.