{"success":true,"name":"react-data-distribution-choose-props-context-or-a-store-befo","description":"React app growing and data is being threaded through many components","category":"ai-brimind","path":"ai-brimind/react-data-distribution-choose-props-context-or-a-store-befo/SKILL.md","file":"SKILL.md","content":"---\nname: react-data-distribution-choose-props-context-or-a-store-befo\ndescription: \"React app growing and data is being threaded through many components\"\n---\n\n# React Data Distribution: Choose Props, Context, or a Store Before the Tree Grows\n\n## When to use\nProject is React, and you're passing props through layers that don't use them, or about to add Context or a state library to escape that.\n\n## Example request\nTheme passed through eight components that just forward it → truly global, rarely-changing values are what Context is for. — Fast-changing form input moved into Context → every consumer re-renders on each keystroke; frequently-changing values don't belong in broad Context. — Fetched server data copied into a global store 'to share it' → it goes stale and needs manual syncing; server cache state is its own category with its own dedicated tools. — Two sibling components need the same value → lifting it to the nearest common parent is enough; a store for a local problem is overkill.\n\n## Instructions\nAct as a city planner who routes each utility by its nature: water, electricity, and mail travel differently, and so should different kinds of state. When data distribution in React gets painful: 1) Classify the data before choosing a mechanism — local UI state (one component or close siblings), truly app-wide and slow-changing (theme, current user, language), fast-changing shared state (live interactions), or server data (fetched, cacheable, refetchable) — misclassification is the root of most state architecture pain. 2) Match mechanism to class: local state stays local or lifts to the nearest common parent; slow-changing global values fit Context; server data belongs in a data-fetching/cache layer, not hand-copied into stores; only genuinely complex, fast-changing shared state earns a state library. 3) Before adding any new mechanism, check what the project already uses — a second store or a parallel pattern for the same job splits the codebase's brain. 4) Respect Context's cost: every consumer re-renders when its value changes, so keep contexts small and split by change frequency rather than making one giant AppContext. 5) Prop drilling through two or three layers is fine and honest — reach for machinery when drilling is deep AND the value is genuinely shared, not at the first inconvenience. If you can't classify the data, trace who reads it, who writes it, and how often it changes — the answers classify it for you. Only introduce a mechanism once the data's class is confirmed, and explain why this mechanism matches how the data actually lives, not just which library is popular.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #975\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}