Loading video...

Video Failed to Load

Go Home

why does React have "Rules of Hooks?"

107,084 views • 1 year ago •via X (Twitter)

11 Comments

James Landrum's profile picture
James Landrum1 year ago

I had a component I needed to work different based on an attribute (I know this is bad, hear me out) - when one way I needed 2 hooks and when the other way I needed 3. So what did I do? Put a dummy hook and lined them up so that react had no idea. Same hooks, same order, completely different behavior. I’m not proud but also am very proud of such garbage.

UserInterface's profile picture
UserInterface2 years ago

Why Reader-Focused Websites Triumph Over Google's Algorithm Shifts #marketing #seo

mox 🐀's profile picture
mox 🐀1 year ago

Feels like the user working for the framework and not the other way around

Dinesh Katariya.'s profile picture
Dinesh Katariya.1 year ago

Wow 😮, so useState uses linked lists under the hood, i thought I was getting infinite re render error due to setState being called infinitely.

Tiger Abrodi's profile picture
Tiger Abrodi1 year ago

my new fav youtuber i guess 😁🔥

Prasenjit's profile picture
Prasenjit1 year ago

That's seriously interesting 💯

Rustcity Рустcитий's profile picture
Rustcity Рустcитий1 year ago

Conditionally calling useState with no returns?

Pete Sena's profile picture
Pete Sena1 year ago

Photo of me battling rules of hooks on most @nextjs projects. Ps thanks @greensock for your newest hook 👏 recently

from's profile picture
from1 year ago

Wait what

Uvaan Covenden's profile picture
Uvaan Covenden1 year ago

I needed this !!

Matt Timmermans's profile picture
Matt Timmermans1 year ago

It's because each time you use a hook in a rerender, it matches the call to the state you created in the last render. The hook calls are matched up sequentially: call 0 to call 0, call 1 to call 1, etc. This is dangerous, so React devs put in some paranoid guardrails.

Related Videos