Skip to content

sickn33/agentic-awesome-skills / plugins/aasb-web-app/skills/react-best-practices

react-best-practices

Verified

Comprehensive performance optimization guide for React and Next.js applications, adapted from Vercel’s published guidance. Use when writing new React components or Next.js pages, implementing data fetching (client or server-side), or reviewing code for performance issues.

FileKindSize
AGENTS.mdmarkdown56.3 KB
README.mdmarkdown1.1 KB
SKILL.mdskill md6.0 KB
metadata.jsonconfig641 B
rules/_sections.mdmarkdown1.5 KB
rules/_template.mdmarkdown631 B
rules/advanced-event-handler-refs.mdmarkdown1.7 KB
rules/advanced-use-latest.mdmarkdown1.4 KB
rules/async-api-routes.mdmarkdown1.4 KB
rules/async-defer-await.mdmarkdown2.2 KB
rules/async-dependencies.mdmarkdown1.1 KB
rules/async-parallel.mdmarkdown874 B
rules/async-suspense-boundaries.mdmarkdown2.7 KB
rules/bundle-barrel-imports.mdmarkdown1012 B
rules/bundle-conditional.mdmarkdown1014 B
rules/bundle-defer-third-party.mdmarkdown1.1 KB
rules/bundle-dynamic-imports.mdmarkdown1.0 KB
rules/bundle-preload.mdmarkdown1.4 KB
rules/client-event-listeners.mdmarkdown2.1 KB
rules/client-swr-dedup.mdmarkdown1.4 KB
rules/js-batch-dom-css.mdmarkdown2.2 KB
rules/js-cache-function-results.mdmarkdown1.8 KB
rules/js-cache-property-access.mdmarkdown638 B
rules/js-cache-storage.mdmarkdown2.0 KB
rules/js-combine-iterations.mdmarkdown753 B
rules/js-early-exit.mdmarkdown1.2 KB
rules/js-hoist-regexp.mdmarkdown1.2 KB
rules/js-index-maps.mdmarkdown1.0 KB
rules/js-length-check-first.mdmarkdown1.7 KB
rules/js-min-max-loop.mdmarkdown2.1 KB
rules/js-set-map-lookups.mdmarkdown532 B
rules/js-tosorted-immutable.mdmarkdown1.9 KB
rules/rendering-activity.mdmarkdown819 B
rules/rendering-animate-svg-wrapper.mdmarkdown1.3 KB
rules/rendering-conditional-render.mdmarkdown980 B
rules/rendering-content-visibility.mdmarkdown1.0 KB
rules/rendering-hoist-jsx.mdmarkdown1.0 KB
rules/rendering-hydration-no-flicker.mdmarkdown1.5 KB
rules/rendering-svg-precision.mdmarkdown794 B
rules/rerender-defer-reads.mdmarkdown973 B
rules/rerender-dependencies.mdmarkdown824 B
rules/rerender-derived-state.mdmarkdown724 B
rules/rerender-functional-setstate.mdmarkdown3.1 KB
rules/rerender-lazy-state-init.mdmarkdown2.4 KB
rules/rerender-memo.mdmarkdown1.3 KB
rules/rerender-transitions.mdmarkdown1.3 KB
rules/server-after-nonblocking.mdmarkdown2.2 KB
rules/server-cache-lru.mdmarkdown1.7 KB
rules/server-cache-react.mdmarkdown899 B
rules/server-parallel-fetching.mdmarkdown1.7 KB
rules/server-serialization.mdmarkdown1.3 KB

rules/js-early-exit.md

View on GitHub
---
title: Early Return from Functions
impact: LOW-MEDIUM
impactDescription: avoids unnecessary computation
tags: javascript, functions, optimization, early-return
---

## Early Return from Functions

Return early when result is determined to skip unnecessary processing.

**Incorrect (processes all items even after finding answer):**

```typescript
function validateUsers(users: User[]) {
  let hasError = false
  let errorMessage = ''
  
  for (const user of users) {
    if (!user.email) {
      hasError = true
      errorMessage = 'Email required'
    }
    if (!user.name) {
      hasError = true
      errorMessage = 'Name required'
    }
    // Continues checking all users even after error found
  }
  
  return hasError ? { valid: false, error: errorMessage } : { valid: true }
}
```

**Correct (returns immediately on first error):**

```typescript
function validateUsers(users: User[]) {
  for (const user of users) {
    if (!user.email) {
      return { valid: false, error: 'Email required' }
    }
    if (!user.name) {
      return { valid: false, error: 'Name required' }
    }
  }

  return { valid: true }
}
```

Returning the first error changes behavior if callers require all errors or the last error. Preserve the chosen validation contract.
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall