TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What are the best practices to apply in large react-hooks code base?

3 点作者 sriram_iyengar超过 5 年前

1 comment

nip超过 5 年前
- refrain from using hooks everywhere, instead, prefer using them in « container » type of components to separate the hard logic from the soft one (cosmetic logic, such as color changes, hiding &#x2F; showing parts of the UI)<p>- Hook-based context is a godsend, but similarly, should be used only when needed (to provide deeply nested components with specific props): passing props around is not a bad thing and makes you think more of your architecture (going through the pain of passing props down might be painful and makes you reflect on the choices you made when designing a specific part of the app).<p>- Folder structure<p>These rules are not about performance (modern frameworks deal with that equally well: the user code is the culprit and there’s no one-size-fits-all advice to improve that), but rather to keep your sanity. It will also help when writing tests as they will be nicely siloed.
评论 #21451157 未加载