Index of every page on this site: llms.txt
All skills
grahamcrackers avatar

/bulletproof-react-patterns

@ca83de4
Run it yourself

Bulletproof React architecture patterns for scalable, maintainable applications. Covers feature-based project structure, component patterns, state management boundaries, API layer design, error handling, security, and testing strategies. Use when structuring a React project, designing application architecture, organizing features, or when the user asks about React project structure or scalable patterns.

Use this Skill: https://skilld.dev/gh/grahamcrackers/skills/bulletproof-react-patterns

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescomponents-and-styling.md

≈975 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Components and Styling

Component Best Practices

Colocate Things Close to Usage

Keep components, functions, styles, and state as close as possible to where they are used. This improves readability and reduces unnecessary re-renders on state updates.

Avoid Nested Rendering Functions

Extract inline rendering functions into separate components:

// Avoid — gets out of control quickly
function Component() {
    function renderItems() {
        return <ul>...</ul>;
    }
    return <div>{renderItems()}</div>;
}

// Prefer — extract to a separate component
function Items() {
    return <ul>...</ul>;
}

function Component() {
    return (
        <div>
            <Items />
        </div>
    );
}

Limit Props

If a component accepts too many props, split it into multiple components or use composition via children or slots.

Wrapping 3rd Party Components

Wrap third-party components to adapt them to your application's API. This isolates the dependency so swapping the underlying library only requires changing one file:

import { Link as RouterLink, type LinkProps as RouterLinkProps } from "react-router";

interface LinkProps extends Omit<RouterLinkProps, "className"> {
    variant?: "default" | "muted";
}

export function Link({ variant = "default", ...props }: LinkProps) {
    return <RouterLink className={linkStyles({ variant })} {...props} />;
}

Component Library

Build abstractions around shared components for consistency and maintainability. Identify repetitions before creating components to avoid wrong abstractions.

Component Hierarchy

Page Components          → route-level, compose features, handle layout
  └── Feature Components → feature-specific, business logic
        └── UI Components      → shared primitives, no business logic

UI Components

  • Stateless where possible — accept data and callbacks via props.
  • Composable — use compound component patterns for complex UI.
  • Polymorphic when needed — use as or asChild for flexible rendering.

Feature Components

Feature components can:

  • Fetch and mutate data (via query hooks).
  • Access feature-specific state.
  • Compose UI components with business logic.
  • Handle feature-specific error and loading states.

Component Libraries

Fully Featured (pre-styled)

  • Chakra UI — great DX, fast prototyping, accessible out of the box
  • AntD — extensive components, best for admin dashboards
  • MUI — most popular, Material Design or headless
  • Mantine — modern, customizable, many built-in hooks

Headless (unstyled)

Best when implementing a custom design system:

Code-Based (copy-paste, styleable)

Pre-built components provided as source code, not packages:

Styling Solutions

Keep React Server Components in mind — they require zero-runtime styling solutions.

Storybook

Use Storybook for developing and testing components in isolation. It serves as a component catalogue for development and discoverability.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo5 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill is an architectural guide for React development, providing best practices for project structure, state management, and testing. It contains exclusively educational content and code examples with no executable or malicious scripts.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • Runlayer9mo

    1/11 files flagged

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at ca83de4. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 9 months ago

README badge

README badge for grahamcrackers/skills/bulletproof-react-patterns