skills/bulletproof-react-components/SKILL.md
Build bulletproof React components that survive SSR, hydration, concurrent rendering, portals, transitions, and future React changes. Nine essential patterns from Shu Ding's guide. Use when writing reusable React components, fixing hydration mismatches, handling SSR edge cases, or building component libraries.
npx skillsauth add codewithshreyans/skills bulletproof-react-componentsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Nine patterns that ensure React components survive real-world conditions beyond the happy path — SSR, hydration, concurrent rendering, portals, and more.
Source: shud.in/thoughts/build-bulletproof-react-components
./references/patterns.md| # | Pattern | Rule |
|---|---------|------|
| 1 | Server-Proof | Never call browser APIs (localStorage, window, document) during render. Use useEffect. |
| 2 | Hydration-Proof | Inject a synchronous inline <script> to set client-dependent values before React hydration. |
| 3 | Instance-Proof | Use useId() for all generated IDs. Never hardcode IDs in reusable components. |
| 4 | Concurrent-Proof | Wrap server data-fetching in React.cache() to deduplicate calls per request. |
| 5 | Composition-Proof | Use Context instead of React.cloneElement() — cloneElement breaks with Server Components, lazy, and memo. |
| 6 | Portal-Proof | Use ref.current?.ownerDocument.defaultView \|\| window for event listeners, not the global window. |
| 7 | Transition-Proof | Wrap state updates in startTransition() to enable View Transition API animations. |
| 8 | Activity-Proof | Use useLayoutEffect to disable DOM side effects (e.g., <style> tags) when hidden by <Activity>. |
| 9 | Future-Proof | Use useState(() => value) for stable identity. useMemo is only a performance hint — React may discard it. |
When building a reusable React component, verify:
useId() (instance-proof)cache() (concurrent-proof)cloneElement (composition-proof)ownerDocument.defaultView (portal-proof)startTransition() where needed (transition-proof)<Activity> visibility (activity-proof)useState initializer, not useMemo (future-proof)When reviewing a component against these patterns, format as:
**Bulletproof Check: `<ComponentName>`**
| Pattern | Status | Notes |
|---------|--------|-------|
| Server-Proof | PASS/FAIL | ... |
| ... | ... | ... |
**Suggested fixes:**
1. ...
./references/patterns.md — Detailed code examples (bad/good) for all nine patternsdevelopment
Comprehensive reference for building Mintlify documentation sites. Use when creating pages, configuring docs.json, adding components, setting up navigation, or working with API references. Routes to detailed reference files for all components and configuration options.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.
development
Run, watch, debug, and extend OpenClaw QA testing with qa-lab and qa-channel. Use when Codex needs to execute the repo-backed QA suite, inspect live QA artifacts, debug failing scenarios, add new QA scenarios, or explain the OpenClaw QA workflow. Prefer the live OpenAI lane with regular openai/gpt-5.4 in fast mode; do not use gpt-5.4-pro or gpt-5.4-mini unless the user explicitly overrides that policy.