简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM