Not reviewed yet: this page may be outdated or inconsistent with the other guides. The API reference is generated from the current source.
Best Practices
Draft. This page is a placeholder. The guidance will be written by the Reagent maintainers; the list below is only an outline of candidate topics, collected from the existing guides.
Candidate topics
- Rendering entry point:
reagent.dom.client/create-rootandrenderfor React 18 and 19, instead of the legacyreagent.dom/render(React 19 and Reagent, Upgrading to 2.0). - Choosing a component style: form-1/2/3 class components vs. function
components and hooks, and when to use
:f>or the function component compiler (Creating Reagent Components, Reagent Compiler, React Features). - Calling components:
[component args]vs.(component args), and whydefccomponents can only be used in Hiccup (Square brackets vs parentheses, What's new in 2.0). - Where state lives: app state in a few ratoms vs. local state in form-2
components or
with-let; cursors, reactions andtrack(Managing State). - Dereferencing: deref inside render, not inside lazy sequences
(or wrap them in
doall) (Component not re-rendering, Managing State). - Props and re-rendering: passing values vs. atoms, equality checks, and keeping props stable (When do components update?).
- Lists and keys:
^{:key ...}metadata vs.:keyprop, and keys to force re-creation (Forcing re-creation). - Inputs: controlled inputs and cursor-jumping workarounds (Controlled Inputs).
- Timing: batching,
r/flush,next-tickandafter-render(Batching and Timing). - React interop:
:>,adapt-react-class,as-element,reactify-component, and refs (Interop with React, Using refs). - Security: untrusted data in
href,dangerouslySetInnerHTMLandunsafe-html(Security).