Загрузка видео...

Не удалось загрузить видео

На главную

<LoadingButton /> No `isLoading`. No `useState` in parents. yield your `onClick` handler.

191,424 просмотров • 5 месяцев назад •via X (Twitter)

Комментарии: 25

Фото профиля Devon Govett
Devon Govett5 месяцев назад

If you use action props, react handles all this for you!

Фото профиля Eric Clemmons 🍊☁️
Eric Clemmons 🍊☁️5 месяцев назад

All of this? 🤨 Since this did some numbers, there’s a less contrived version where this shines. But it means I need to use effect ;)

Фото профиля Devon Govett
Devon Govett5 месяцев назад

Well maybe not the “taking longer than usual” part, but it’ll handle the loading states for sure

Фото профиля Eric Clemmons 🍊☁️
Eric Clemmons 🍊☁️5 месяцев назад

Ooh ok. I thought there was something I missed. Thanks for clarifying Devon 🫡

Фото профиля Eric Clemmons 🍊☁️
Eric Clemmons 🍊☁️5 месяцев назад

You should the rest of my projects 😭

Фото профиля Seb ⚛️ ThisWeekInReact.com
Seb ⚛️ ThisWeekInReact.com5 месяцев назад

Any interactive blog post to link to, please? 😅

Фото профиля Eric Clemmons 🍊☁️
Eric Clemmons 🍊☁️5 месяцев назад

I’ll write something for you today

Фото профиля Seb ⚛️ ThisWeekInReact.com
Seb ⚛️ ThisWeekInReact.com5 месяцев назад

Thanks 😀

Фото профиля Seb ⚛️ ThisWeekInReact.com
Seb ⚛️ ThisWeekInReact.com5 месяцев назад

Let me know if you still plan to write it :) BTW please add a blog RSS feed so that I don't miss it

Фото профиля Eric Clemmons 🍊☁️
Eric Clemmons 🍊☁️5 месяцев назад

Almost done - one last example to write

Фото профиля Seb ⚛️ ThisWeekInReact.com
Seb ⚛️ ThisWeekInReact.com5 месяцев назад

perfect :)

Фото профиля irfan
irfan5 месяцев назад

Interesting concept! I would probably want to yield label + state + icon + isDisabled + ...otherProps, combined, instead of just the label.

Фото профиля Eric Clemmons 🍊☁️
Eric Clemmons 🍊☁️5 месяцев назад

Thats right! Returning Partial<LoadingButton.Props> is way better 💪

Фото профиля freddie
freddie5 месяцев назад

cool idea generators are sexy but you can’t represent a full state with linear iterators

Фото профиля Eric Clemmons 🍊☁️
Eric Clemmons 🍊☁️5 месяцев назад

Oh?

Фото профиля Cristian
Cristian5 месяцев назад

I can't tell if you're trolling or not

Фото профиля Rodolfo Silva → salao365.com
Rodolfo Silva → salao365.com5 месяцев назад

Nice work, this is very handy! Do you have a real-world example? Something like using this approach with React Query, or calling an API directly?

Фото профиля Ilya
Ilya5 месяцев назад

never thought of using generators like that, looks cool

Фото профиля milksense – oss/acc
milksense – oss/acc5 месяцев назад

useless 😁

Фото профиля Pochi
Pochi5 месяцев назад

pattern looks clean! what if the user doubleclicks before the await resolves, you wld need an AbortController inside or a guard otherwise you race the previouss yield??

Фото профиля Felipe
Felipe5 месяцев назад

what

Фото профиля Brand Buff
Brand Buff5 месяцев назад

Can't imagine scenario how I would yield in the middle of long await to notify user It would be better if button had these breakpoints in the its own api

Фото профиля Eric Clemmons 🍊☁️
Eric Clemmons 🍊☁️5 месяцев назад

I normally have an API with discreet states like After 3s, if it’s a multi-step process the visibility into “loading” or even showing a live timer is a much better UX imo

Фото профиля Z
Z5 месяцев назад

I like it

Фото профиля HJ
HJ5 месяцев назад

this is sexy

Похожие видео

Oh no it happened again >///<
0:26

Sensitive content

Oh no it happened again >///<

Henrythehusky

16,772 просмотров • 3 лет назад