React components often contain a mix of four different responsibilities:
In general, it's a good idea to separate these as much as possible and to not combine them in a single component. As a general guideline keep view code away from non-view code.
Hooks can be a good place to store non-view logic, and then pass that to a component like normal to render. They offer better encapsulation. Even better is regular functions and classes, as it keeps you from coupling directly to React.
Views change more frequently than non-view logic. Keeping them separate aids maintainability.
These practices:
As always, nuance is important. For very small components it can make sense to keep everything contained in a single component.
https://martinfowler.com/articles/modularizing-react-apps.html
[[20210202103254-coupling-cohesion]] [[20230130013027-separation-of-concerns]]