Why you should clean up react effects using fetch

Why you should clean up react effects using fetch

Web Dev Cody

1 год назад

10,073 Просмотров

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


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

@WrestlingTournamentsDotCom
@WrestlingTournamentsDotCom - 01.02.2024 08:12

This is just what I needed. Thank you.

Ответить
@_Sonato
@_Sonato - 20.11.2023 07:50

I really think you should get into the habit of using guard clauses instead of these single line if/else statements.

Ответить
@tahielgomez
@tahielgomez - 08.10.2023 02:18

really helpfull. thanks!!

Ответить
@vnm_8945
@vnm_8945 - 10.11.2022 02:21

very nice, keep up with the good work, we' learnin' here. :D

Ответить
@dcknature
@dcknature - 06.11.2022 22:29

Thanks for showing us the proper way to handle this kind of situations 👍!
Some apps are infamous for doing it the lazy way, plus confusing their users with ambiguous messages like: "No connection!", when the user's connection is absolutely fine 😁.

Ответить
@adarsh-chakraborty
@adarsh-chakraborty - 04.11.2022 13:52

I like these short informative videos

Ответить
@raphaelgorbach1476
@raphaelgorbach1476 - 04.11.2022 05:28

Hi reletivaly new to react, how do I do this when I call a function in useEffect that does the fetching for me? Don't I then have to pass the signal as an argument so I have an object reference to that abort controller? Also woudn't this be consider bad practice since the called function would then be impure?

Ответить
@orlie9621
@orlie9621 - 03.11.2022 23:07

AbortController is more reliable cause it prevents unnecessary fetching

Ответить
@szabolcsjobbagy30
@szabolcsjobbagy30 - 03.11.2022 20:00

It's very nice that
besides showing the code (even 2 or more alternative solutions of the same problem)
you tell us the reasons as well, the concept behind it, why are these good/bad practices,

we can learn a lot from you,
Thank You!!

Ответить
@lukor-tech
@lukor-tech - 03.11.2022 18:30

This is something I needed and I didn't know I did.

Ответить
@niklassoderberg2168
@niklassoderberg2168 - 03.11.2022 17:51

Great! (video)

Ответить
@jacktrusler6506
@jacktrusler6506 - 03.11.2022 17:32

Man I could've used this video like 2 months ago, trying to find good info on this was annoying... great simple explanation.

Ответить
@aishanstha
@aishanstha - 03.11.2022 17:30

useEffect is called after each render and when setState is used inside of it, it will cause the component to re-render which will call useEffect and so on and so on.

Ответить
@StiflerNR
@StiflerNR - 03.11.2022 17:21

Would something like this work with React + Redux + Redux-Saga + Service layer (built on open-api generator) ?
In useEffect im dispatching action which go to saga => saga calls a service => service returns data and set them to ReduxStore

Something like i generate AxiosCancelationToken in UseEffect --> send it to saga -> map it to service.method({ options: { cancelationToken: tokenFromUseEffect }})

and then in cleanUp function in useffect i trigger cancelationToken (Axiox.CancelToken.source().cancel())

Is this correct way ?

Ответить
@CraigClayton-bk3ze
@CraigClayton-bk3ze - 03.11.2022 17:20

Another great video.

Ответить
@user-ls5pg2wd4i
@user-ls5pg2wd4i - 03.11.2022 16:57

We learning boys

Ответить
@Harish-rz4gv
@Harish-rz4gv - 03.11.2022 16:37

Where can I find you classroom app

Ответить
@nemanjavucic6653
@nemanjavucic6653 - 03.11.2022 16:21

Firstly, I hit like and then start to watch

Ответить
@SeibertSwirl
@SeibertSwirl - 03.11.2022 16:02

Good job babe!!!!!

Ответить