正在加载视频...

视频加载失败

why does React have "Rules of Hooks?"

107,084 次观看 • 1 年前 •via X (Twitter)

11 条评论

James Landrum 的头像
James Landrum1 年前

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 的头像
UserInterface2 年前

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

mox 🐀 的头像
mox 🐀1 年前

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

Dinesh Katariya. 的头像
Dinesh Katariya.1 年前

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 的头像
Tiger Abrodi1 年前

my new fav youtuber i guess 😁🔥

Prasenjit 的头像
Prasenjit1 年前

That's seriously interesting 💯

Rustcity Рустcитий 的头像
Rustcity Рустcитий1 年前

Conditionally calling useState with no returns?

Pete Sena 的头像
Pete Sena1 年前

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

from 的头像
from1 年前

Wait what

Uvaan Covenden 的头像
Uvaan Covenden1 年前

I needed this !!

Matt Timmermans 的头像
Matt Timmermans1 年前

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.

相关视频