React tips: Update state the CORRECT way

React tips: Update state the CORRECT way

WebDevEducation

4 года назад

17,871 Просмотров

Ссылки и html тэги не поддерживаются


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

@newerainfantasy6535
@newerainfantasy6535 - 12.08.2023 17:50

Hats off to your valuable brain.

Ответить
@vmsoory2141
@vmsoory2141 - 09.08.2023 21:01

❤❤❤

Ответить
@ganeshlimbu4353
@ganeshlimbu4353 - 15.03.2023 20:02

❤❤

Ответить
@hakan126
@hakan126 - 13.01.2023 01:00

How do I set state in a loop?
For example a loop that has a save button of every record on clicking would be saved true.

On setting the set state , it changes the state as saved to every single record instead of the one that was clicked.

Ответить
@aleksandarv.1459
@aleksandarv.1459 - 18.12.2022 17:41

Keep up the good work!

Ответить
@katjazenker5160
@katjazenker5160 - 01.08.2022 16:10

been looking for a good explaination on why to use prevState for a while and this is it!! :) thanks alot.

Ответить
@samkim5612
@samkim5612 - 12.04.2022 20:18

Thank you...

Ответить
@rorycawley8334
@rorycawley8334 - 27.09.2021 22:11

Thanks Tom, mad that the setCount function can either take a number or a function.

Ответить
@vibhavrathee6788
@vibhavrathee6788 - 25.09.2021 14:56

You are GOD! I had a similar issue. thank you thank you very much

Ответить
@vinayrwt
@vinayrwt - 11.04.2021 11:18

Great 👌

Ответить
@sazol
@sazol - 04.04.2021 14:12

Saved my project 🙂. Thanks a lot.

Ответить
@billbarsch
@billbarsch - 26.01.2021 07:07

🤯

Ответить
@dannyman2200
@dannyman2200 - 23.01.2021 14:49

nice video!

Ответить
@jonathanyngfors3905
@jonathanyngfors3905 - 01.11.2020 12:28

How come setTimeout() pass the argument before it fires setCount?

Ответить
@MrKaremnour
@MrKaremnour - 09.08.2020 05:29

Try catch and learn, right?

Ответить
@persv988
@persv988 - 06.04.2020 11:20

Just discovered the "set" function pattern your showing here, can be really useful in some async scenarios!

It's a "gotcha" that you have to persist any events etc. if you'r just using it to capture a form value update for example. Since by the time your set lambda runs the event has been reused.
So I guess in those scenarios it's still preferable to just use the updateValue({name: e.target.value}) directly so you don't have to persist? Guess it's not a one size fits all here but...

Spagetti style function declaration withing function body is somewhat oldstyle no?
()=>{ function callback(){ function nestedCallback(){ }}} etc etc....
Aren't you suppose to use useCallback to handle that kind of scenario?

Thnx for sharing!

Ответить
@vyacheslavzgordan6725
@vyacheslavzgordan6725 - 05.04.2020 11:09

Great, looks like I made such errors earlier, thank you for make it clear

Ответить
@hsdev
@hsdev - 04.04.2020 02:00

Thank for this tip Tom, this is good to know.

Ответить