mcpField
R
react-best-practices

react-best-practices

github.com/redpanda-dataDevelopment4.4k81 installsUpdated today
Repository

About react-best-practices

A React performance skill for developers, organizing 29 optimization rules by category and impact across bundles, rendering, async work, and browser behavior.

Key features

  1. 0129 rules grouped by category and impact
  2. 02Bundle size optimization guidance
  3. 03Re-render prevention patterns
  4. 04Rendering and async recommendations
  5. 05JavaScript and browser practices

Use cases

  1. 01Investigating component re-render issues
  2. 02Reducing bundle size
  3. 03Reviewing useEffect and useMemo patterns

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/redpanda-data/console --skill react-best-practices

After installing, type/react-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

rules/
advanced-event-handler-refs.md
advanced-use-latest.md
async-defer-await.md
async-dependencies.md
async-suspense-boundaries.md
bundle-barrel-imports.md
bundle-code-splitting.md
bundle-preload.md
client-event-listeners.md
client-passive-event-listeners.md
js-batch-dom-css.md
js-caching-patterns.md
js-index-maps.md
js-length-check-first.md
js-tosorted-immutable.md
rendering-activity.md
rendering-animate-svg-wrapper.md
rendering-conditional-render.md
rendering-content-visibility.md
rendering-hoist-jsx.md
rendering-svg-precision.md
rerender-defer-reads.md
rerender-dependencies.md
rerender-derived-state.md
rerender-functional-setstate.md
rerender-lazy-state-init.md
rerender-memo.md
rerender-simple-expression-in-memo.md
rerender-transitions.md
use-effect.md

Details

From the project README

React Best Practices

Client-side React optimization patterns for Cloud UI. 29 rules organized by category and impact.

Activation Conditions

  • Performance optimization tasks
  • Component re-render issues
  • Bundle size concerns
  • useEffect/useMemo patterns

Rules by Category

Bundle Optimization (CRITICAL)
RuleKey Point
bundle-barrel-importsImport from source files, not barrel index.ts
bundle-code-splittingReact.lazy + Suspense for heavy components, conditional loads, deferred 3rd-party
bundle-preloadPreload critical resources
Re-render Prevention (HIGH)
RuleKey Point
rerender-memoMemoize expensive computations
rerender-dependenciesMinimize hook dependency arrays
rerender-derived-stateCompute during render, not in effects
rerender-functional-setstatesetState(prev => ...) to avoid stale closures
rerender-lazy-state-inituseState(() => expensive()) not useState(expensive())
rerender-simple-expression-in-memoDon't memoize trivial expressions
rerender-transitionsuseTransition for non-urgent updates
rerender-defer-readsRead URL params / storage inside callbacks, not at render
Rendering (MEDIUM)
RuleKey Point
rendering-conditional-renderShort-circuit with && / ternary, avoid render in effects
rendering-hoist-jsxMove static JSX outside components
rendering-content-visibilityCSS content-visibility: auto for off-screen
rendering-activityReact <Activity> for hidden UI
rendering-animate-svg-wrapperWrap animated SVGs to isolate re-renders
rendering-svg-precisionLimit SVG coordinate precision
Async (MEDIUM)
RuleKey Point
async-suspense-boundariesGranular <Suspense> boundaries
async-defer-awaitDon't await non-blocking work
async-dependenciesLoad deps in parallel, not sequentially
JavaScript (MEDIUM)
RuleKey Point
js-caching-patternsModule-level Map caches for repeated calls + storage reads
js-batch-dom-cssBatch DOM reads/writes to avoid layout thrashing
js-index-mapsPre-index arrays into Maps for O(1) lookups
js-length-check-firstCheck .length before expensive operations
js-tosorted-immutableUse .toSorted() / .toReversed() for immutable transforms

RegExp hoisting is enforced by Biome (useTopLevelRegex).

Browser (MEDIUM)
RuleKey Point
client-event-listenersClean up event listeners in useEffect return
client-passive-event-listeners{ passive: true } for scroll/touch handlers
Advanced (LOW)
RuleKey Point
advanced-event-handler-refsStable callback refs to avoid child re-renders
advanced-use-latestuseLatest pattern for always-current values in callbacks

Comments

Markdown supported