Small but important correction - in these trivial examples you *can* use setCount(count => count + 1) to get around one issue I showed (assuming your code is that simple/trivial) In the real world this is not always an option though, our full article explains in better detail: www.builder.io/blog/usesignal-is-the-future-of-web-frameworks
It would be better to demonstrate this in the video itself. It's harmful to show this to beginners and make them rush out to install yet another dependency to fix something that is already built into react.
That's smart. I always used React Class component so I didn't notice this. Reading comments like yours is actually more informative than the video itself 🎉
so react people are just using observables (rebranded as signals) for state management now.. why do we still need the vdom then? the observable dependency tree tells you exactly which components should update, no?
React doesn’t natively support signals and has publicly said they don’t plan to add it. You can get something similar with Jotai though but without granular (high perf) rendering
@@maelstrom-qw1jl Even creating elements dynamically can be done. Just call a function with parameters defined with LET (not VAR) variables and inside that function you can make html elements and bind event listeners to them easily. Updating content of those elements is trickier. There, I usually use document.getElementById The benefit is much faster load time than frameworks
@@archmad compared to the garbage someone dared to call "react", even though it requires 100's of megabytes of external packages to actually become "reactive"? Yes. Just learn Vue or Svelte.
@@archmad It's perfectly solveable. But I don't see why I would need to work around a problem like this in the first time. It's not really a good developer experience. This is only one of many things that made me ditch React for 90% of my projects.
@@archmadRight. Let's ignore the fact that it's more intuitive to have a set of variables bound to the UI's state and literally just reassign them if needed - like in Svelte. Let's stick with the frameworks that use terribly designed reactivity patterns and require hundereds of lines of code to do something other frameworks do in just about 10 lines... It's not about which one is easier... Svelte is all: - Easier - Faster in execution - Faster to work with (which means cheaper and shorter development) - Requires about an afternoon to learn compared to about a year? (again meaning less costs for you or your company) - And oh... Doesn't cause keybords to fly across streets all around the globe when the devs want to quit their jobs over silly errors you could find in seconds if the code was more readable (just saying)
Small but important correction - in these trivial examples you *can* use setCount(count => count + 1) to get around one issue I showed (assuming your code is that simple/trivial)
In the real world this is not always an option though, our full article explains in better detail: www.builder.io/blog/usesignal-is-the-future-of-web-frameworks
It would be better to demonstrate this in the video itself. It's harmful to show this to beginners and make them rush out to install yet another dependency to fix something that is already built into react.
If it’s not an option then either the design sucks or the framework sucks. Why complicate things
You can also use reducers or even refs for this, there are so many workarounds that doesn't involve a new framework
Your solving issues your bad code created.
@@turolretar ones can’t ask a JS dev why over complicate things
Those bastards never saw rust or go in their lives
Man!!! We really made web dev so complicated 🎉😂
use callback for setState not change your entire framework..., react and solid just work differently
What about callback function in setstate
I was going to say this exact thing
then it will work
That's smart. I always used React Class component so I didn't notice this.
Reading comments like yours is actually more informative than the video itself 🎉
Cool, you reinvented the way it worked in 2017.
We also can use just a prevState so count will be updated by 1 normally
totally agree with that man
I love how svelte just works with none of this cruft.
It's amazing that people are still hanging onto React...
Bruh don't say that. It's been just 6 months working as a react dev.
so react people are just using observables (rebranded as signals) for state management now..
why do we still need the vdom then? the observable dependency tree tells you exactly which components should update, no?
because the components are created first in the v-dom and then rendered to the actual dom?
There is no need for sure, Leptos does it and performance is huge.
You can also create custom useInterval hook that saves the function inside a ref object so the function will be updated through render.
I’m at a convention. Pregaming and waiting for ppl to show up and now all I want to do is try out signals. Lmaoo.
whats the difference between useSignal and signal
Set state has a previous value in the lambda… just use that
but setCount support functions isn't it?
solid-js can be used in react-native?
Bro what did you use the learn JS so well?
It’s practice
Practice practice theres no easier way unfortunately you practice succeed fail and keep trying again
It's really basic JS.
@@yadusolparterre Ironically starting an interval is basic JS, getting it to work with React is intermediate.
@@yadusolparterre no its not. Its react which is not basic js, al lot more going on here than basic js
man, SPA's are really a shit-show now. band-aids on top of band-aids...
Why you crying just pick vue if the rest of them are hard
How about just having a local variable in the setState function to hold the current count and post updates using setCount?
How does he use editor for such a clean recording?
Yeah I can do this with svelte in 2 lines of code and don’t require a virtual DOM. 😂
Right anguler is good also react.
use return in setState
Eh! setCount(x => x+1) looks simpler than signal version!
Qwik, solid, preat and soon angular? How about react lol
React doesn’t natively support signals and has publicly said they don’t plan to add it. You can get something similar with Jotai though but without granular (high perf) rendering
Angular?
This honestly looks much easier to do in vanilla Javascript lol
Aside from creating elements dynamically, pretty much everything is easier to do with vanilla JS now.
@@maelstrom-qw1jl Even creating elements dynamically can be done. Just call a function with parameters defined with LET (not VAR) variables and inside that function you can make html elements and bind event listeners to them easily.
Updating content of those elements is trickier. There, I usually use document.getElementById
The benefit is much faster load time than frameworks
if you are doing timer, yes. handling UI and global state? cmon
@@archmad compared to the garbage someone dared to call "react", even though it requires 100's of megabytes of external packages to actually become "reactive"?
Yes. Just learn Vue or Svelte.
Isn't this just what RxJS has done since forever?
react should me deprecated ..
Stuff like this is why I ditched React for Svelte.
my respect, Bro!
Maybe you ditched the react learning halfway 🗿
you ditched it because you cant solve the rerender issue on a timer? you are not a good developer then.
@@archmad It's perfectly solveable. But I don't see why I would need to work around a problem like this in the first time. It's not really a good developer experience.
This is only one of many things that made me ditch React for 90% of my projects.
@@archmadRight. Let's ignore the fact that it's more intuitive to have a set of variables bound to the UI's state and literally just reassign them if needed - like in Svelte.
Let's stick with the frameworks that use terribly designed reactivity patterns and require hundereds of lines of code to do something other frameworks do in just about 10 lines...
It's not about which one is easier...
Svelte is all:
- Easier
- Faster in execution
- Faster to work with (which means cheaper and shorter development)
- Requires about an afternoon to learn compared to about a year? (again meaning less costs for you or your company)
- And oh... Doesn't cause keybords to fly across streets all around the globe when the devs want to quit their jobs over silly errors you could find in seconds if the code was more readable (just saying)
Who's obsessed?
If your code is working leave it untouched.
Or you can just use a ref.
Vue > React
React was a mistake.
Are people really obsessed with Signals?! Is this a fact of life now? 😂😂
Your tuts ain’t for beginners
Cringes is python
Ugly design.
useEffect(() => {
if (!isStart) return;
const interval = setInterval(() => {
setTime((prev) => {
const a = prev - 1;
document.title = secondToString(a);
return a;
});
}, 1000);
return () => clearInterval(interval);
}, [isStart]);
If you dont know how to fix this, which you didnt show in the video, you are not qualify to judge React
React hooks are stupid try coming up with a reason for why it's better than whatever already existed lol
Why can’t react just add this to their own 🥹
exactly how i feel