正在加载视频...

视频加载失败

A cure for React useState hell? You may not realize how easily you can replace useState with useReducer and simplify your state management You can read more in my latest blog post:

609,313 次观看 • 3 年前 •via X (Twitter)

10 条评论

Steve (Builder.io) 的头像
Steve (Builder.io)3 年前

Huge kudos to @DavidKPiano for first pointing this out in his epic thread:

Steve (Builder.io) 的头像
Steve (Builder.io)3 年前

If you are interested in this topic and want to read further, I go into more detail in my blog post:

Steve (Builder.io) 的头像
Steve (Builder.io)3 年前

And follow @DavidKPiano - he is the creator of XState and @statelyai and posts tons of great content and tips on state management patterns

Steve (Builder.io) 的头像
Steve (Builder.io)3 年前

Also if you are a fan of YouTube I’ve started posting videos there as well

Marton Sari 的头像
Marton Sari3 年前

To me it makes no sense to do validation like that. The pattern you reach with this is silent errors all around. If you want user input validation, you do it with an explicit mechanism with feedback (client/server/isomorph). If you want dev consistency, you do it on type level.

Steve (Builder.io) 的头像
Steve (Builder.io)3 年前

Generally speaking, imo you should have both

Erik Rasmussen 👨‍💻🇺🇸🇪🇸 的头像
Erik Rasmussen 👨‍💻🇺🇸🇪🇸3 年前

@DavidKPiano This is super cool. I feel like you made a typo in the video (and blog post). Surely this should be `Math.min(next, 10)`, right?

Steve (Builder.io) 的头像
Steve (Builder.io)3 年前

@DavidKPiano Doh, yes, thank you!

Vibbs Dod 的头像
Vibbs Dod3 年前

Have you checked out Learnt about it from new react beta docs, might help with pain points that you are talking about.

Steve (Builder.io) 的头像
Steve (Builder.io)3 年前

Wrote about this in the blog post, Immer is amazing

相关视频