Component organization and architecture patterns.
File size limits:
Component organization:
File structure:
components/, not shared/Use sub-components (e.g., <Icon />) instead of render functions (e.g., getIcon()).
Benefits:
React component files must not exceed 500 lines.
Extract logic to hooks, sub-components, or utilities when approaching this limit.
File size guidance:
GraphQL files MUST be co-located with the component/hook that uses them (GraphQL near operation pattern).
query.graphqlquery-list.graphql, query-detail.graphqlsubscription.graphql or subscription-*.graphqlmutation.graphql or mutation-*.graphqlfragments.graphql (when shared within feature)For larger features:
Key principles:
graphql/ folder: Don't create module-level graphql/ foldersOne component/hook = one concern.
Favor small, composable components over "god" components.
Use Error Boundaries to protect pages from crashes. Always log errors to Datadog.
π¨ ALL HOOKS MUST BE UNIT TESTED π¨
See Unit Testing for comprehensive testing patterns.
For more detailed technical guidance, see these reference files:
On this page