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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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 3useEffect()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 moreuseEffect()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.