DEV Community

Discussion on: How I moved from React to Svelte

Collapse
 
artazasameen profile image
Artaza Sameen

As long as your intention to build small and personal projects . Sevelte is fine. But, at scale it is better to choose React. Helps in the long run

Collapse
 
webjose profile image
José Pablo Ramírez Vargas • Edited

As I told @kedzior_io, I made the same thing in Svelte and React: A simple timer (countdown). I started with Svelte. Used a readable store to keep track of the time and then calculated the hours, minutes and seconds to present the time formatted. Done.

Let's do React. While it basically needed the same, I of course had to use useState() for everything or the UI doesn't update. Svelte used regular variables for hours, minutes and seconds. Not React. No, sir. useState() everywhere. Anyway, I did 3 useEffect() calls to calculate the whole thing. Done.

Svelte's version: Flawless. I even animated the timer values with fly. React's? Nope. Needs more work. Needs local variables to hold the hours, minutes and seconds calculation, or you need more useEffect() calls because everything is behind one cycle. The result is that 59 seconds is never shown as s59. It shows -1, then 58. There's also an odd behavior: When the React tab is not visible for some minutes, the seconds count is negative! It comes up normal in the next iteration of the number.

Conclusion: Svelte just works. React needs to be made to work. The latter requires more learning effort or more talent than the former.

Collapse
 
kedzior_io profile image
Artur Kędzior • Edited

I manage 3 different teams and I have very interesting observation with regards to that.

So I would say it depends.

On one project I have a team of React developers working on huge Svelte project and the results are great, the team enjoys it and is capable of translating their skills into Svelte. The code base has an amazing simplicity that any newcomer is able to pick it up in no time. There is no component for a specific thing it's so easy to write one.

On another project I have very experienced React team working on React Js and React Native and although it is also going great, but we lived through some serious performance problems and very silly bugs and I think the main issue was the fact that the code is not easy to understand and you can easily loose the track what happens when. Also any bigger package upgrades caused problems while with Svelte we have nearly finished a full blown e-commerce with only 2 dependencies (Tailwind UI and Headless-UI).

My small project is getting a great traction: salarioo.com which I'm hoping it's going to get bigger and feature rich. I will share my experience then!

I encourage you to try if you haven't yet.