react-best-practices
यह क्या करती है
यह स्किल अच्छी परफ़ॉर्मेंस वाला React कोड लिखने और जांचने का मार्गदर्शन देती है। इसमें लोडिंग की देरी से बचना, बंडल छोटा रखना और बेवजह के री-रेंडर घटाना शामिल है।
कब इस्तेमाल करें
- ✓जब आप नए React कॉम्पोनेंट या डेटा फ़ेचिंग कोड लिख रहे हों।
- ✓जब आप React कोड में स्पीड या आकार की समस्याएँ जांच रहे हों।
- ✓जब आपका React ऐप धीरे लोड हो या बहुत बार री-रेंडर हो।
Skill का लिंक
https://github.com/mastra-ai/mastra/blob/main/.claude/skills/react-best-practices/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरा React डैशबोर्ड लोड होने में धीमा है। कॉम्पोनेंट जांचिए और सबसे बड़े परफ़ॉर्मेंस सुधार बताइए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट कोड को प्राथमिकता वाले नियमों से जांचता है, सबसे ज़्यादा असर वाले नियमों से शुरू करते हुए, जैसे लोडिंग की कतार और बंडल आकार। फिर वह असर के क्रम में बदलाव सुझाता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
React Best Practices
Overview
Routing and priority guide for React performance and quality, containing 27 rules across 9 categories. Rule files hold the detailed explanations, examples, review smells, and impact metrics.
When to Apply
Reference these guidelines when:
- Writing new React components
- Implementing data fetching
- Reviewing code for performance issues
- Refactoring existing React code
- Optimizing bundle size or load times
Priority-Ordered Guidelines
Rules are prioritized by impact:
| Priority | Category | Impact |
|---|---|---|
| 1 | Eliminating Waterfalls | CRITICAL |
| 2 | Bundle Size Optimization | CRITICAL |
| 3 | Client-Side Data Fetching | MEDIUM-HIGH |
| 4 | Re-render Optimization | MEDIUM |
| 5 | Rendering Performance | MEDIUM |
| 6 | JavaScript Performance | LOW-MEDIUM |
| 7 | Component Structure | MEDIUM-HIGH (maintainability) |
| 8 | Testing | MEDIUM-HIGH (correctness) |
| 9 | Type Safety | HIGH |
Quick Reference
Critical Patterns (Apply First)
Eliminate Waterfalls:
- Use
Promise.all()for independent async operations (async-parallel)
Reduce Bundle Size:
- Avoid barrel file imports, import directly from source (
bundle-barrel-imports) - Defer non-critical third-party libraries (
bundle-defer-third-party)
Medium-Impact Patterns
Client-Side Data Fetching:
- Use Tanstack Query for automatic request deduplication (
client-request-dedupe) - Dependent query params are the value or
undefined, never| nullor a fake fallback; narrow at the caller so hooks stay strict, or guard withskipTokenwhen the hook must accept an optional param (client-request-dedupe)
Re-render Optimization:
- Use lazy state initialization for expensive values (
rerender-lazy-state-init) - Apply
startTransitionfor non-urgent updates (rerender-transitions) - Keep UI handlers plain; use Effect Events only for effect-fired logic (
rerender-useeffect-function-calls) - Never reset state with
useEffect; lift the discriminant and remount the branch (rerender-no-useeffect-state-reset) - Never add
useMemooruseCallback; leave memoization decisions to developers with profiler evidence (rerender-no-usememo-usecallback) - Never call
setStateduring render or insideuseEffect; derive during render or move state ownership to an intermediate component (rerender-no-setstate-in-render-or-effect)
Component Structure:
- One domain component/hook per file, one responsibility each — split bloated components (
structure-single-responsibility) - Keep component, hook, function, and utility APIs narrow: split oversized props, arguments, and return objects into focused units composed at the component level; wrapping the same values in one object is not a fix (
structure-narrow-apis) - Use PascalCase components for JSX-returning helpers; keep lowercase helpers for non-JSX values (
structure-component-naming) - Derive props/params instead of accepting a value computable from another arg (
structure-derive-dont-duplicate) - Extract complex derived logic into named locals plus predicates or pure helpers with early returns: oversized conditions, nested ternaries, ternaries that compute instead of picking (multi-line branches, or an
ascast re-asserting what the condition tested), fallback chains, andlet-based render prep are code smells, in render prep and in hook options, request builders, config maps, and reducers alike (structure-complex-derived-logic) - Pick the view with early
ifguards but keep the layout wrapper in one place — branch a body component, don't ternary or duplicate the shell (structure-early-return-render-branches) - For a fixed set of items, write one component per item with explicit props that owns its data and loading — don't map a config-object array onto a component shape (
structure-composition-over-config) - When a domain component fetches data, render through a pure layout component that positions slots, and branch the slot contents between skeletons and resolved sub-domain components (
structure-data-fetching-layout)
Testing:
- BDD tests that d
अक्सर पूछे जाने वाले सवाल
पहले क्या ठीक होता है?
सबसे बड़े असर वाले क्षेत्र, जैसे लोडिंग की कतारें खत्म करना और बंडल आकार घटाना।
क्या इसमें टेस्टिंग भी शामिल है?
हाँ। परफ़ॉर्मेंस के साथ इसमें टेस्टिंग और टाइप सुरक्षा का मार्गदर्शन भी है।
क्या यह केवल एक फ़्रेमवर्क के लिए है?
यह आम React कोड के लिए है, और उदाहरण व नियम आम React ऐप पर लागू होते हैं।
जानकारी
लेखक का मूल विवरण
React performance optimization guidelines from Mastra Engineering. This skill should be used when writing, reviewing, or refactoring React code to ensure optimal performance patterns. Triggers on tasks involving React components, data fetching, bundle optimization, or performance improvements.
repo: mastra-ai/mastra
लोकप्रियता
- GitHub स्टार
- 29k
- रैंकिंग में स्थान
- #9365
- लाइसेंस
- —
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
debugging-difficult-bugs
29kयह आपके एजेंट को कठिन बग ढूंढने में मदद करती है, असली प्रोग्राम के रनटाइम लॉग से, केवल टेस्ट देखकर अंदाज़ा लगाने की जगह।
mastra-frontend
29kयह आपके एजेंट को Mastra playground डिज़ाइन सिस्टम के तैयार कॉम्पोनेंट जोड़कर ऐप स्क्रीन बनाने में मदद करती है, शुरू से स्टाइल करने की जगह।
pr-explainer
29kयह आपके एजेंट को पुल रिक्वेस्ट को एक साफ़, स्व-निहित HTML पेज में बदलने में मदद करती है, जो रिव्यूअर को बदलाव समझाए।
pr-splitter
29kयह आपके एजेंट को एक बड़ी, उलझी पुल रिक्वेस्ट को छोटी, रिव्यू योग्य पुल रिक्वेस्ट में बांटने में मदद करती है, मूल काम सुरक्षित रखते हुए।
मिलती-जुलती skills
angular-developer
280kआपके एजेंट को Angular code बनाने और प्रोजेक्ट स्ट्रक्चर पर सलाह देने में मदद करता है। नए प्रोजेक्ट शुरू करने, code के हिस्से बनाने, या performance और accessibility सुधारने में उपयोगी है।
frontend-a11y
280kआपके एजेंट को web interfaces को सबके लिए accessible बनाने में मदद करता है। यह सुनिश्चित करता है कि websites और apps screen readers और keyboard navigation के साथ अच्छे से काम करें।
frontend-patterns
280kआपके एजेंट को React और Next.js में frontend development के modern patterns लागू करने में मदद करता है। यह performance optimize करता है, state manage करता है और best practices फॉलो करवाता है।