filmov
tv
Build react useFetch from scratch | with check list, tests and examples

Показать описание
In this video CJ shows how to implement a useFetch react hook from scratch. He shows how to manage data and loading state. He also shows how to handle fetch errors, parse errors and request cancellations. He provides a test suite, checklist and examples so you can practice implementing this hook yourself.
00:00 intro
03:14 repo setup
03:30 example hook usage
04:46 repo walk-through
05:00 test setup
05:40 stubbed implementation
06:03 call fetch on mount
06:46 manage loading state
09:11 manage data state
10:41 handle options immediate
12:30 handle re-renders
16:09 handle empty url
17:41 handle fetch errors
19:12 handle json parse error
19:38 handle update calls
21:12 handle abort error
23:18 resetting state on load
24:30 handle multiple requests
28:53 cancel request on unmount
30:00 thanks!
Corrections:
19:29 The test "should handle http errors correctly" has been added to the repo since video release. See notes in src/use-fetch/README.md.
------------------------------------------------------------------------------
Hit us up on Socials!
#react #typescript #testing
00:00 intro
03:14 repo setup
03:30 example hook usage
04:46 repo walk-through
05:00 test setup
05:40 stubbed implementation
06:03 call fetch on mount
06:46 manage loading state
09:11 manage data state
10:41 handle options immediate
12:30 handle re-renders
16:09 handle empty url
17:41 handle fetch errors
19:12 handle json parse error
19:38 handle update calls
21:12 handle abort error
23:18 resetting state on load
24:30 handle multiple requests
28:53 cancel request on unmount
30:00 thanks!
Corrections:
19:29 The test "should handle http errors correctly" has been added to the repo since video release. See notes in src/use-fetch/README.md.
------------------------------------------------------------------------------
Hit us up on Socials!
#react #typescript #testing
Комментарии