{"slug":"react-patterns","title":"react-patterns","summary":"Modern React patterns and principles. Hooks, composition, performance, TypeScript best practices.","platform":"ChatGPT","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-08-16T13:38:48.887231Z","repo":{"url":"https://github.com/sickn33/agentic-awesome-skills","stars":46883,"forks":6831,"license":"MIT","updatedAt":"2026-09-25T05:43:16Z"},"bodyHtml":"<hr>\n<h2>name: react-patterns\ndescription: \"Modern React patterns and principles. Hooks, composition, performance, TypeScript best practices.\"\nrisk: safe\nsource: community\ndate_added: \"2026-02-27\"</h2>\n<h1>React Patterns</h1>\n<blockquote>\n<p>Principles for building production-ready React applications.</p>\n</blockquote>\n<hr>\n<h2>1. Component Design Principles</h2>\n<h3>Component Types</h3>\n<table>\n<thead>\n<tr>\n<th>Type</th>\n<th>Use</th>\n<th>State</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>Server</strong></td>\n<td>Data fetching, static</td>\n<td>None</td>\n</tr>\n<tr>\n<td><strong>Client</strong></td>\n<td>Interactivity</td>\n<td>useState, effects</td>\n</tr>\n<tr>\n<td><strong>Presentational</strong></td>\n<td>UI display</td>\n<td>Props only</td>\n</tr>\n<tr>\n<td><strong>Container</strong></td>\n<td>Logic/state</td>\n<td>Heavy state</td>\n</tr>\n</tbody>\n</table>\n<h3>Design Rules</h3>\n<ul>\n<li>One responsibility per component</li>\n<li>Props down, events up</li>\n<li>Composition over inheritance</li>\n<li>Prefer small, focused components</li>\n</ul>\n<hr>\n<h2>2. Hook Patterns</h2>\n<h3>When to Extract Hooks</h3>\n<table>\n<thead>\n<tr>\n<th>Pattern</th>\n<th>Extract When</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>useLocalStorage</strong></td>\n<td>Same storage logic needed</td>\n</tr>\n<tr>\n<td><strong>useDebounce</strong></td>\n<td>Multiple debounced values</td>\n</tr>\n<tr>\n<td><strong>useFetch</strong></td>\n<td>Repeated fetch patterns</td>\n</tr>\n<tr>\n<td><strong>useForm</strong></td>\n<td>Complex form state</td>\n</tr>\n</tbody>\n</table>\n<h3>Hook Rules</h3>\n<ul>\n<li>Hooks at top level only</li>\n<li>Same order every render</li>\n<li>Custom hooks start with \"use\"</li>\n<li>Clean up effects on unmount</li>\n</ul>\n<hr>\n<h2>3. State Management Selection</h2>\n<table>\n<thead>\n<tr>\n<th>Complexity</th>\n<th>Solution</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Simple</td>\n<td>useState, useReducer</td>\n</tr>\n<tr>\n<td>Shared local</td>\n<td>Context</td>\n</tr>\n<tr>\n<td>Server state</td>\n<td>React Query, SWR</td>\n</tr>\n<tr>\n<td>Complex global</td>\n<td>Zustand, Redux Toolkit</td>\n</tr>\n</tbody>\n</table>\n<h3>State Placement</h3>\n<table>\n<thead>\n<tr>\n<th>Scope</th>\n<th>Where</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Single component</td>\n<td>useState</td>\n</tr>\n<tr>\n<td>Parent-child</td>\n<td>Lift state up</td>\n</tr>\n<tr>\n<td>Subtree</td>\n<td>Context</td>\n</tr>\n<tr>\n<td>App-wide</td>\n<td>Global store</td>\n</tr>\n</tbody>\n</table>\n<hr>\n<h2>4. React 19 Patterns</h2>\n<h3>New Hooks</h3>\n<table>\n<thead>\n<tr>\n<th>Hook</th>\n<th>Purpose</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>useActionState</strong></td>\n<td>Form submission state</td>\n</tr>\n<tr>\n<td><strong>useOptimistic</strong></td>\n<td>Optimistic UI updates</td>\n</tr>\n<tr>\n<td><strong>use</strong></td>\n<td>Read resources in render</td>\n</tr>\n</tbody>\n</table>\n<h3>Compiler Benefits</h3>\n<ul>\n<li>Automatic memoization</li>\n<li>Less manual useMemo/useCallback</li>\n<li>Focus on pure components</li>\n</ul>\n<hr>\n<h2>5. Composition Patterns</h2>\n<h3>Compound Components</h3>\n<ul>\n<li>Parent provides context</li>\n<li>Children consume context</li>\n<li>Flexible slot-based composition</li>\n<li>Example: Tabs, Accordion, Dropdown</li>\n</ul>\n<h3>Render Props vs Hooks</h3>\n<table>\n<thead>\n<tr>\n<th>Use Case</th>\n<th>Prefer</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Reusable logic</td>\n<td>Custom hook</td>\n</tr>\n<tr>\n<td>Render flexibility</td>\n<td>Render props</td>\n</tr>\n<tr>\n<td>Cross-cutting</td>\n<td>Higher-order component</td>\n</tr>\n</tbody>\n</table>\n<hr>\n<h2>6. Performance Principles</h2>\n<h3>When to Optimize</h3>\n<table>\n<thead>\n<tr>\n<th>Signal</th>\n<th>Action</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Slow renders</td>\n<td>Profile first</td>\n</tr>\n<tr>\n<td>Large lists</td>\n<td>Virtualize</td>\n</tr>\n<tr>\n<td>Expensive calc</td>\n<td>useMemo</td>\n</tr>\n<tr>\n<td>Stable callbacks</td>\n<td>useCallback</td>\n</tr>\n</tbody>\n</table>\n<h3>Optimization Order</h3>\n<ol>\n<li>Check if actually slow</li>\n<li>Profile with DevTools</li>\n<li>Identify bottleneck</li>\n<li>Apply targeted fix</li>\n</ol>\n<hr>\n<h2>7. Error Handling</h2>\n<h3>Error Boundary Usage</h3>\n<table>\n<thead>\n<tr>\n<th>Scope</th>\n<th>Placement</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>App-wide</td>\n<td>Root level</td>\n</tr>\n<tr>\n<td>Feature</td>\n<td>Route/feature level</td>\n</tr>\n<tr>\n<td>Component</td>\n<td>Around risky component</td>\n</tr>\n</tbody>\n</table>\n<h3>Error Recovery</h3>\n<ul>\n<li>Show fallback UI</li>\n<li>Log error</li>\n<li>Offer retry option</li>\n<li>Preserve user data</li>\n</ul>\n<hr>\n<h2>8. TypeScript Patterns</h2>\n<h3>Props Typing</h3>\n<table>\n<thead>\n<tr>\n<th>Pattern</th>\n<th>Use</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Interface</td>\n<td>Component props</td>\n</tr>\n<tr>\n<td>Type</td>\n<td>Unions, complex</td>\n</tr>\n<tr>\n<td>Generic</td>\n<td>Reusable components</td>\n</tr>\n</tbody>\n</table>\n<h3>Common Types</h3>\n<table>\n<thead>\n<tr>\n<th>Need</th>\n<th>Type</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Children</td>\n<td>ReactNode</td>\n</tr>\n<tr>\n<td>Event handler</td>\n<td>MouseEventHandler</td>\n</tr>\n<tr>\n<td>Ref</td>\n<td>RefObject</td>\n</tr>\n</tbody>\n</table>\n<hr>\n<h2>9. Testing Principles</h2>\n<table>\n<thead>\n<tr>\n<th>Level</th>\n<th>Focus</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Unit</td>\n<td>Pure functions, hooks</td>\n</tr>\n<tr>\n<td>Integration</td>\n<td>Component behavior</td>\n</tr>\n<tr>\n<td>E2E</td>\n<td>User flows</td>\n</tr>\n</tbody>\n</table>\n<h3>Test Priorities</h3>\n<ul>\n<li>User-visible behavior</li>\n<li>Edge cases</li>\n<li>Error states</li>\n<li>Accessibility</li>\n</ul>\n<hr>\n<h2>10. Anti-Patterns</h2>\n<table>\n<thead>\n<tr>\n<th>❌ Don't</th>\n<th>✅ Do</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Prop drilling deep</td>\n<td>Use context</td>\n</tr>\n<tr>\n<td>Giant components</td>\n<td>Split smaller</td>\n</tr>\n<tr>\n<td>useEffect for everything</td>\n<td>Server components</td>\n</tr>\n<tr>\n<td>Premature optimization</td>\n<td>Profile first</td>\n</tr>\n<tr>\n<td>Index as key</td>\n<td>Stable unique ID</td>\n</tr>\n</tbody>\n</table>\n<hr>\n<h2>11. File Structure</h2>\n<img width=\"1150\" height=\"1438\" alt=\"image\" src=\"https://github.com/user-attachments/assets/10369698-472c-4695-a494-2c0672103aa1\">\n<p>Use this image as a reference for a better file structure of the project</p>\n<hr>\n<blockquote>\n<p><strong>Remember:</strong> React is about composition. Build small, combine thoughtfully.</p>\n</blockquote>\n<h2>When to Use</h2>\n<p>This skill is applicable to execute the workflow or actions described in the overview.</p>\n<h2>Limitations</h2>\n<ul>\n<li>Use this skill only when the task clearly matches the scope described above.</li>\n<li>Do not treat the output as a substitute for environment-specific validation, testing, or expert review.</li>\n<li>Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.</li>\n</ul>\n","files":[{"path":"SKILL.md","sizeBytes":4465,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-08-16T13:44:44.196876Z","sha256":"E2445724D674FAAF4C5A5505B6365778D51DE144E17106C4D0655930FEE82E5F","sizeBytes":2222},"review":null,"source":{"repositoryUrl":"https://github.com/sickn33/agentic-awesome-skills","path":"skills/react-patterns","license":"MIT","commit":"f2bba339de74414b0771234cbe4f6a15258e32a3","subtreeSha":"E86065614D099A183425CA50638E60213F5BD59616852102DE5F22F089323BB0","lastSyncedAt":"2026-09-25T06:48:39.853703Z"},"reviewedAt":"2026-08-16T13:54:08.091535Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/sickn33/agentic-awesome-skills/tree/main/skills/react-patterns"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install sickn33-agentic-awesome-skills@llmmart"},{"target":"git","command":"git clone https://github.com/sickn33/agentic-awesome-skills.git"}]}