मुख्य सामग्री पर जाएँ
Skillpedia
वेबसाइट और UI (frontend)29k · #9365

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 पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/mastra-ai/mastra/blob/main/.claude/skills/react-best-practices/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

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 | null or a fake fallback; narrow at the caller so hooks stay strict, or guard with skipToken when 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 startTransition for 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 useMemo or useCallback; leave memoization decisions to developers with profiler evidence (rerender-no-usememo-usecallback)
  • Never call setState during render or inside useEffect; 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 as cast re-asserting what the condition tested), fallback chains, and let-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 if guards 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

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

debugging-difficult-bugs

29k

यह आपके एजेंट को कठिन बग ढूंढने में मदद करती है, असली प्रोग्राम के रनटाइम लॉग से, केवल टेस्ट देखकर अंदाज़ा लगाने की जगह।

कोडिंगटेस्टिंग

mastra-frontend

29k

यह आपके एजेंट को Mastra playground डिज़ाइन सिस्टम के तैयार कॉम्पोनेंट जोड़कर ऐप स्क्रीन बनाने में मदद करती है, शुरू से स्टाइल करने की जगह।

कोडिंगवेबसाइट और UI (frontend)

pr-explainer

29k

यह आपके एजेंट को पुल रिक्वेस्ट को एक साफ़, स्व-निहित HTML पेज में बदलने में मदद करती है, जो रिव्यूअर को बदलाव समझाए।

कोडिंगसामान्य कोडिंग

pr-splitter

29k

यह आपके एजेंट को एक बड़ी, उलझी पुल रिक्वेस्ट को छोटी, रिव्यू योग्य पुल रिक्वेस्ट में बांटने में मदद करती है, मूल काम सुरक्षित रखते हुए।

कोडिंगसामान्य कोडिंग

मिलती-जुलती skills