DEV Community

Cover image for React Hooks are Dead? How Signals Are Taking Over

React Hooks are Dead? How Signals Are Taking Over

Kinanee Samson on December 15, 2023

React Hooks are dead and it's official! hooks have always been the traditional way of handling state and running side-effects in our React componen...
Collapse
 
brense profile image
Rense Bakker

We've had signals-like implementations in state management libs for react for quite some time, however these aren't real signals. The concept of signals was made popular by solidjs (signals is the backbone of solidjs) and got a lot of attention when angular adopted the same pattern. React cannot do real signals, because it needs to always traverse the entire component tree, which goes against the principles of signals. Signals implementations in React are just a facade that visually make it look like signals, but if you look at the source, you will see that they use some form of observer lib like rxjs to subscribe to state updates and then normal react useState hook, which will trigger a traversal of the entire component tree in the vdom.

Collapse
 
kalashin1 profile image
Kinanee Samson

Yes I agree with the part where you said they used RXJS under the hood. When I first checked signals out the first thing that came to my mind is no way React is doing this thing by default. Something else is happening under the hood.

I didn't know about signal like implementation in other state management libraries.

Collapse
 
josemunoz profile image
José Muñoz

I'm pretty sure signals were already popular on linux development before solidJS came to exist

Collapse
 
brense profile image
Rense Bakker

Hah, well we'll have to ask Ryan where he got the idea then :p

Collapse
 
usulpro profile image
Oleg Proskurin

React Hooks are dead and it's official!

Official by whom? Can you please share a link to React (not Preact) documentation? I didn't even see a mention of signals in the official documentation.
If this article about Preact why I see React in the title and keywords?

Collapse
 
kalashin1 profile image
Kinanee Samson

Are you sure you took your time to read through the whole article?

Collapse
 
oz profile image
Evgeniy OZ

I did read it, and also didn't find any confirmation of this bold claim. Only a link to your YouTube channel.

Thread Thread
 
kalashin1 profile image
Kinanee Samson

Oh I see where the confusion is, well I actually attended the funeral where we laid Hooks to rest.

Anyway if you did read the full article then you'd see where I stated "Personally in my humble opinion signals will replace some hooks but not all hooks".

The goal of this post at the end the day is not to prove that React hooks are dead rather it is to introduce the concept of signals in a friendly way.

I know you don't want them to take hooks away yes we all love using hooks but if there's something that gets the job done more easier than hooks I don't know about you but I'll definitely go for it.

Thread Thread
 
oz profile image
Evgeniy OZ

There is no confusion, you just use a false claim, and that’s it.

Collapse
 
gregorygaines profile image
Gregory Gaines

To clear confusion I think @usulpro is referring to your use of "official" included in your claims with no "official" announcement anywhere. I've read the entire article and it changed nothing.

Collapse
 
nienow profile image
Matthew Nienow

Signals is the reason I started using SolidJS instead of React. The only downside was not being able to take advantage of the huge React ecosystem. I will have to give these a try. Thanks for the article.

Collapse
 
kalashin1 profile image
Kinanee Samson

You're welcome. Now React has it's own implementation of signals hopefully you can start using React.

Collapse
 
phinguyen202 profile image
Phi Nguyen

Hey @kalashin1, do you mean Preact?

Thread Thread
 
kalashin1 profile image
Kinanee Samson

No, I meant for React. However the signal Library was built by Preact.

Thread Thread
 
phinguyen202 profile image
Phi Nguyen

Can you link the documentation here?

Thread Thread
 
kalashin1 profile image
Kinanee Samson
Thread Thread
 
phinguyen202 profile image
Phi Nguyen

React and Preact are different libraries man!
Please make it clear that "React doesn't have it's own implementation of signals yet"

Collapse
 
jackmellis profile image
Jack

Interesting and I'm not against the idea of signals but I honestly can't see the advantage of signals over hooks at this point. Feels like we're (once again) reinventing the wheel.

Also you basically get this out-of-the-box with Vue, the entire render engine is based around this sort of concept.

Collapse
 
kalashin1 profile image
Kinanee Samson

We are always moving back and forth in the world web app development.

Collapse
 
codingjlu profile image
codingjlu

I hate to be that guy, but if React hooks were dead why do approximately 99% of React apps (past, present, and foreseeable future) still use them?

Collapse
 
kalashin1 profile image
Kinanee Samson

Because it's what developers are used to and hey hooks still help us get the job done.

Collapse
 
codingjlu profile image
codingjlu

So... they're not dead? 😂

Thread Thread
 
kalashin1 profile image
Kinanee Samson

not totally 😂

Collapse
 
voltra profile image
Voltra

Hold on... are you trying to say that React will finally be... reactive? It only took 10 years for the name not to be ironic

Collapse
 
kalashin1 profile image
Kinanee Samson

😂 everything isn't the way it always seem.

Collapse
 
srbhr profile image
Saurabh Rai

Hey @kalashin1 really nice post.

Can you create a similar for Angular as well? We've got signals over there as well. 😂

Collapse
 
kalashin1 profile image
Kinanee Samson

It's been really long since I used Angular but hey I'm going to try my best.

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
benherbst profile image
Comment marked as low quality/non-constructive by the community. View Code of Conduct
Info Comment hidden by post author - thread only accessible via permalink
Ben Herbst

fdsfds

Collapse
 
Sloan, the sloth mascot
Comment deleted
 
Sloan, the sloth mascot
Comment deleted
 
Sloan, the sloth mascot
Comment deleted
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
hanmant1999 profile image
Hanmant Petekar

How can i update the signal , is it just a like updating the object value using the key ?

Collapse
 
kalashin1 profile image
Kinanee Samson

totally.

signal.value = newValue

Enter fullscreen mode Exit fullscreen mode

Some comments have been hidden by the post's author - find out more