Skip to main content
@usenarrator/plugin-react The React plugin reads a component the way you would describe a screen: what it keeps track of, what it shows, and what happens when someone clicks, types or submits. JSX becomes a description of the UI, so a <button onClick={...}> reads as “a button” with what it does when clicked, and a list rendered with map reads as “for each todo in visible”.
The plugin declares library: { name: "react", versions: ">=18 <20" }. It reads JSX as UI in files that import React, react-dom or Next.js, or that belong to a package depending on one of them (see Dependency detection). Files written for other JSX libraries, such as Solid or Preact, are left alone. If you use Next.js, use the Next.js plugin instead, because it already includes this one.

Examples

State, conditions and lists
English
Effects, memos and refs
English
Actions, Suspense and lazy components
English

What it covers

  • Components: function and arrow components, their props, memo, forwardRef, lazy, render functions and class components that call setState.
  • JSX as UI: HTML elements by what they are (a heading, a checkbox, a link to a page), conditional rendering with &&, ternaries and early returns, lists rendered with map, fragments, and event handlers with one or several steps.
  • Hooks: useState and functional updates, useEffect and useLayoutEffect with their dependencies and cleanups, useMemo, useCallback, useRef, useReducer and dispatch, context, custom hooks, useTransition, useDeferredValue and useId.
  • React 19: useActionState, useOptimistic, useFormStatus, use() and form actions.
  • react-dom: createRoot, render and createPortal.

Options

react({ elements }) takes extra readings for elements from other libraries, keyed by JSX tag. Each rule receives the engine, the tag and an attr(name) lookup, and returns the element’s description together with the attributes it has already described, or null to let the default reading apply. The Next.js plugin uses this to read Link, Image, Script and Form.

Translating

The English phrasebook is exported as en and typed as ReactPhrases.