AaronR
AaronR

Reputation: 71

Can I use a custom hook inside of a custom hook?

I'm trying to separate logic in my app and I was wondering If is it possible to call a custom hook inside another custom hook

Upvotes: 7

Views: 13346

Answers (2)

Aleksei Korkoza
Aleksei Korkoza

Reputation: 447

You can call a custom hook inside another custom one. I offer to read this article to use it right away. Link: https://reactjs.org/warnings/invalid-hook-call-warning.html#breaking-the-rules-of-hooks

Upvotes: 1

Evert
Evert

Reputation: 99525

Yes. Just follow the main rules of hooks. Don't call them conditionally, etc.

Upvotes: 3

Related Questions