How you can use custom hooks to abstract your react code

How you can use custom hooks to abstract your react code

Web Dev Cody

2 года назад

8,413 Просмотров

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


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

@astb01
@astb01 - 18.08.2023 20:41

This is much cleaner and it also allows you to unit test the hook - yes you will have more files to manage but you at least get like you say, a decoupled entity

Ответить
@Keinjojo
@Keinjojo - 20.08.2022 23:56

to make your code step up to the next level you could finally use typescript

Ответить
@johnobiofiong
@johnobiofiong - 20.08.2022 01:33

This is exactly how i started writing my react applications...
It really makes your code cleaner

Ответить
@sergeismirnov9340
@sergeismirnov9340 - 09.08.2022 07:40

thanks for the video

what's your vscode theme name?

Ответить
@benkogan1579
@benkogan1579 - 09.08.2022 02:06

Alright so...

Ответить
@Pareshbpatel
@Pareshbpatel - 08.08.2022 23:25

{2022-08-08}

Ответить
@Aaditya1ad
@Aaditya1ad - 08.08.2022 22:17

How would you handle multiple api calls that depend on each other? Just curious

Ответить
@darkzennn
@darkzennn - 08.08.2022 20:14

Great. I would love to see how you abstract even further the pagination with a hook`usePagination`. I have seen myself using that pattern before where I return page, handleNextPage/handlePreviousPage.

Ответить
@theprimecoder4981
@theprimecoder4981 - 08.08.2022 19:07

Ever since I learned react and Nextjs, I've started to use that approach. I find it to be a great way to design your web application

Ответить
@DanteMishima
@DanteMishima - 08.08.2022 18:57

I do something similar for some of my code for calls to CMSes....

Ответить
@ГенаПетров-н5ы
@ГенаПетров-н5ы - 08.08.2022 16:41

Just moving the problem to another file. It won't help from refactoring.

Ответить
@dashawk
@dashawk - 08.08.2022 16:24

Are you using ATOM as your IDE?

Ответить
@reaper_
@reaper_ - 08.08.2022 16:07

the only custom hook I used is a useAuth hook to check if the user is authenticated, and if he has the correct role to access certain routes/actions.

Ответить
@SeibertSwirl
@SeibertSwirl - 08.08.2022 16:01

Good job babe!!!!

Ответить