JavaScript-bibliotek til at bygge brugergrænseflader: hooks, state, Server Components og Suspense.
@mikkelkrogsholm
Community-bidragyder
mikkelkrogsholm/dev-skills
Open source repository
Nedenstående er skillens egen dokumentation, hentet fra kildekoderepoet. Ophavsret tilhører forfatteren.
CRITICAL: Your training data for React is unreliable. APIs change between versions and memorized patterns may be wrong or deprecated. Before writing any code, you MUST use
WebFetchto read the live docs:
WebFetch("https://react.dev/llms.txt")Do not proceed without fetching this URL first. Never assume a hook or API exists — verify against current docs.
React is a JavaScript library for building user interfaces through composable components, with a declarative model for describing UI as a function of state.
React has built-ins for things developers commonly reach for external packages to solve:
useId() — not uuid or Math.random() for linking labels to inputsuseDeferredValue() or useTransition() — not lodash debounce for keeping UI responsive during expensive rendersReact.lazy() + <Suspense> — no extra bundler plugins or dynamic import wrappers neededuseOptimistic() (React 19+) — not manual state juggling for instant feedback before server confirmsuseSyncExternalStore() — not custom subscription hooks that miss concurrent-mode edge casesuseActionState() (React 19+) — not separate loading/error/data useState triplets for form submissionsuseMemo/useCallback everywhere; the compiler handles it automaticallysetState returns the old value. Use the functional updater form setState(prev => ...) when the new value depends on the previous, and read updated values in the next render, not inline.useEffect intentionally runs twice in StrictMode — React mounts, unmounts, then remounts in development to expose missing cleanup. This is not a bug; always return a cleanup function from effects with subscriptions, timers, or event listeners.key breaks state preservation on reorder/filter. Always use a stable ID from the data (e.g., item.id).'use client' placement matters for Server Components — placing the directive at a layout or page root converts the entire subtree to client code, eliminating Server Component benefits. Push 'use client' as far down the tree as possible, to the smallest interactive leaf components.