Awesome-omni-skill benefriches-react-best-practices

React best practices and performance optimization for Benefriches (Vite + Redux). Reference when writing components, implementing Redux patterns, reviewing code quality, or optimizing performance.

install
source · Clone the upstream repo
git clone https://github.com/diegosouzapw/awesome-omni-skill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/development/benefriches-react-best-practices-majiayu000" ~/.claude/skills/diegosouzapw-awesome-omni-skill-benefriches-react-best-practices && rm -rf "$T"
manifest: skills/development/benefriches-react-best-practices-majiayu000/SKILL.md
source content

React Best Practices for Benefriches

Performance optimization guidelines for React 19+ SPA with Vite + Redux

Based on: Vercel React Best Practices

Adapted for: Client-side rendering only


When to Apply This Skill

Use these practices when:

  • ✅ Writing new React components
  • ✅ Implementing Redux thunks or selectors
  • ✅ Reviewing code for performance issues
  • ✅ Refactoring existing React code
  • ✅ Optimizing bundle size
  • ✅ Improving rendering performance
  • ✅ Debugging slow interactions or waterfalls

Rule Categories by Priority

PriorityCategoryRulesImpact
🔴Bundle Size4200-800ms import cost reduction
🟠Async/Waterfall42-10× improvement
🟡Array/Data2Fast-fail + immutability
🟢Re-render12Prevent unnecessary renders
🔵Bundle (Continued)2Load on demand
🟣Client Data2Scroll + storage optimization
Rendering Performance7Static hoisting + transitions
JavaScript Performance11Caching + O(1) lookups
🔘Advanced Patterns2Singletons + stable refs

Total: 31 applicable practices


Quick Reference by Category

🔴 CRITICAL: Bundle Size Optimization

RuleImpactRelevance
Avoid Barrel File Imports200-800ms import costCheck
@/features
imports
Dynamic Imports for Heavy Comp.Reduce initial bundleLazy-load maps, forms, charts
Promise.all() for Independence2-10× parallel speedupRedux thunks fetching multiple resources
Dependency-Based ParallelizationStart async ops ASAPComplex thunks with multiple dependencies

🟠 HIGH: Async/Waterfall Optimization

RuleImpactRelevance
Defer Await Until NeededAvoid blocking code pathsConditional logic in thunks
Strategic Suspense BoundariesShow wrapper UI immediatelyFeature pages with async requirements
Conditional Module LoadingLoad heavy libs on demandCharts, PDFs, advanced map features
CSS content-visibility~10× faster for long listsSite lists, project tables

🟡 MEDIUM-HIGH: Array/Data Optimization

RuleImpactRelevance
Early Length CheckFast-fail expensive opsRedux selectors, form validation
Use toSorted() Instead of sort()Immutability (critical!)ALL sorting in reducers/selectors

🟢 MEDIUM: Re-render Optimization

RuleImpactRelevance
Calculate Derived State in RenderAvoid redundant stateRedux selectors
Extract to Memoized ComponentsEnable early returnsHeavy presentational components
Functional setState UpdatesPrevent stale closuresAlready followed via Redux
Lazy State InitializationCompute expensive values onceLocal state with complex init
Use Transitions for Non-Urgent UpdatesMaintain UI responsivenessSearch/filter inputs
Use useRef for Transient ValuesAvoid re-rendersAnimation values, scroll positions
Narrow Effect DependenciesReduce effect re-runsExtract specific values from objects
Put Logic in Event HandlersAvoid state + effect modelingForms, user interactions
Subscribe to Derived StateBoolean from continuous valuesRedux selectors for UI state
Defer State Reads to Usage PointRead dynamic state in callbacksEvent handlers
Don't Wrap Simple ExpressionsAvoid over-optimizationSimple calculations
Extract Default Non-primitive ParamsPreserve memoizationMemoized component props

🔵 MEDIUM: Bundle Optimization (Continued)

RuleImpactRelevance
Defer Non-Critical LibrariesLoad after initializationAnalytics, error tracking
Preload Based on User IntentReduce perceived latencyHeavy modals, project forms

🟣 MEDIUM: Client Data Patterns

RuleImpactRelevance
Passive Event ListenersEliminate scroll delayInfinite scroll, animations
Version + Minimize localStoragePrevent breaks, reduceRedux persistence, preferences

⚫ LOW-MEDIUM: Rendering Performance

RuleImpactRelevance
Hoist Static JSXAvoid re-creationEmpty states, error messages
Use Activity Component for VisibilityPreserve state/DOMToggle forms/maps
Explicit Conditional RenderingPrevent rendering 0Count displays
useTransition Over Manual LoadingBuilt-in pending stateReplace useState loading flags
Optimize SVG PrecisionReduce file sizeMap icons, illustrations
Animate SVG WrapperHardware accelerationSpinning icons

⚪ LOW-MEDIUM: JavaScript Performance

RuleImpactRelevance
Cache Repeated Function CallsModule-level MapsArea calculations, transformations
Build Index MapsO(1) vs O(n) lookupsRedux selectors by ID
Use Set/Map for LookupsO(1) membership checksSelected IDs, uniqueness filtering
Avoid Layout ThrashingBatch DOM reads/writesAnimations, dynamic layouts
Cache Property Access in LoopsHot path optimizationArray iterations
Cache Storage API CallsAvoid repeated readslocalStorage access
Combine Array IterationsSingle loop vs multipleChained filter/map operations
Early Return from FunctionsSkip unnecessary workValidation functions
Hoist RegExp CreationDon't create in renderEmail validation, parsing
Loop for Min/Max vs SortO(n) vs O(n log n)Finding extremes

🔘 LOW: Advanced Patterns

RuleImpactRelevance
Initialize App OnceModule-level guardsRedux store, analytics setup
Store Event Handlers in RefsStable subscriptionsEvent bus listeners

Benefriches-Specific Integration

Redux Patterns

Already following these best practices:

  • ✅ Functional updates (reducers use immutable patterns)
  • ✅ Derived state in selectors (not duplicated in state)
  • ✅ Deferred state reads (useAppSelector in components)

Apply these explicitly:

  • 🟡 Use
    toSorted()
    instead of
    sort()
    in all reducers/selectors
  • 🟢 Single ViewData selector per container (already following)
  • 🔴 Parallel async in thunks with
    Promise.all()

Clean Architecture Integration

Core layer (business logic):

  • ✅ Pure functions - already optimizable with caching/memoization
  • ✅ No framework deps - easy to extract heavy computations

Infrastructure layer (gateways):

  • 🟠 Conditional module loading - load heavy services on demand
  • 🔵 Preload on intent - import services before API calls

Views layer (React components):

  • 🟢 React.memo() for heavy presentational components with lots of potential re-render (DO NOT pre-optimize when it's not necessary)
  • Hoist static JSX - extract constants outside components
  • 🟠 Suspense boundaries - wrap data-dependent sections

Path Aliases (
@/
)

When optimizing imports:

  • 🔴 Avoid barrel files - use direct paths with
    @/
    alias
  • Example:
    import { X } from '@/features/create-site/core/createSite.reducer'

See Also

  • Full detailed guide:
    AGENTS.md
    in this skill directory
  • Web app guide:
    apps/web/CLAUDE.md
  • Monorepo guide: Root
    CLAUDE.md
  • Original source: Vercel React Best Practices

END OF QUICK REFERENCE - For code examples and detailed patterns, see

AGENTS.md
.