简体   繁体   English

我可以在自定义挂钩中使用自定义挂钩吗?

[英]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链接: https://reactjs.org/warnings/invalid-hook-call-warning.html#break-the-rules-of-hooks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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