Design a React component architecture with composition patterns, prop interfaces, and rendering optimization strategies.
## CONTEXT React applications that start simple inevitably grow into 500+ component codebases where prop drilling spans 8 levels deep, state management becomes a tangled web of contexts and reducers, and new developers spend weeks just understanding the component hierarchy before writing a single line of feature code. Teams that invest in deliberate component architecture from the start ship features 2-3x faster than those who let structure emerge organically, because clear component boundaries, composition patterns, and prop interfaces eliminate the ambiguity that slows down every pull request review and debugging session. ## ROLE You are a senior frontend architect who has designed React component architectures for applications with over 800 components serving 20 million monthly active users. You led the frontend platform team at a major fintech company where you established the component design system that reduced new feature development time by 45% and cut UI-related bugs by 60%. You are deeply versed in React composition patterns including compound components, render props, custom hooks, and higher-order components, and you have strong opinions — backed by production data — on when each pattern is the right choice and when it becomes an over-engineering trap. ## RESPONSE GUIDELINES - Define every component with TypeScript interfaces specifying required and optional props with explicit types - Use composition patterns that match the actual complexity of the UI — do not force compound components where simple props suffice - Include concrete performance optimization points with specific React APIs like memo, useMemo, useCallback, and lazy - Provide a clear testing strategy per component type rather than a generic testing recommendation - Do NOT create deeply nested component hierarchies — flatten where possible and use composition over inheritance - Do NOT define components with more than 8 props — if a component needs more, it should be decomposed or use a context ## TASK CRITERIA 1. **Component Tree Design** — Analyze [INSERT FEATURE DESCRIPTION] and break it into a hierarchical component tree. For each component, classify it as a container (data-fetching, state management), presentational (pure rendering), or compound (multi-part interactive) component. Include the full tree structure described in text. 2. **TypeScript Prop Interfaces** — Define complete TypeScript interfaces for each component including required and optional props, callback function signatures, children types, and ref forwarding. Provide concrete type definitions, not generic Record or any types. 3. **Composition Pattern Selection** — For each complex component interaction, recommend the specific composition pattern: compound components for multi-part UI elements, render props for flexible rendering customization, custom hooks for shared stateful logic, and context for deep data passing. Justify why the chosen pattern fits better than alternatives. 4. **State Architecture** — Map every piece of state to its owner component: local state for UI-only concerns, lifted state for sibling communication, context for cross-tree data, and server state managed through [INSERT STATE COMPLEXITY] patterns. Define the data flow direction for each state relationship. 5. **Reusability Assessment** — Identify components that should be extracted into a shared library versus feature-specific components. Define the abstraction level for each shared component: fully generic, domain-aware, or feature-specific. Include API design guidelines for shared components. 6. **Performance Optimization Plan** — Identify specific rendering bottlenecks: unnecessary re-renders from reference-unstable props, large list rendering, heavy computation in render paths, and bundle size from eager imports. Prescribe React.memo boundaries, virtualization candidates, and code splitting points. 7. **Accessibility Architecture** — Define accessibility requirements per component: ARIA roles and attributes, keyboard navigation patterns, focus management for modals and dropdowns, and screen reader announcements for dynamic content updates. 8. **Testing Blueprint** — Specify the testing approach per component type: unit tests with React Testing Library for presentational components, integration tests for container components, interaction tests for compound components, and visual regression tests for design-critical UI elements. ## INFORMATION ABOUT ME - My feature description: [INSERT FEATURE DESCRIPTION — e.g., multi-step checkout form, dashboard with draggable widgets, real-time chat interface] - My UI design reference: [INSERT UI DESCRIPTION — e.g., Figma link description, wireframe overview, existing similar product] - My existing component library: [INSERT COMPONENT LIBRARY — e.g., internal design system, Material UI, shadcn/ui, building from scratch] - My state complexity: [INSERT STATE COMPLEXITY — e.g., mostly server state with React Query, complex client state with Redux, minimal local state] - My performance requirements: [INSERT PERFORMANCE NEEDS — e.g., must render 1000+ row tables, sub-100ms interactions, mobile-first] - My team React experience: [INSERT TEAM EXPERIENCE — e.g., junior team new to React, senior team familiar with advanced patterns] ## RESPONSE FORMAT - Begin with a component tree diagram described in text showing the full hierarchy with component types labeled - Include a TypeScript interface reference section with complete prop definitions for each component - Provide a composition pattern decision table mapping each complex interaction to its recommended pattern with justification - Use labeled sections for state architecture, performance, and testing with specific implementation guidance - Include example code snippets for the 3 most architecturally significant components - End with a build sequence showing which components to implement first based on dependency order
Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[INSERT FEATURE DESCRIPTION][INSERT STATE COMPLEXITY]