Genie React

Find wasted re-renders in React Native with an AI agent: one tap rendered 29 components

An agent drove an Expo app on the iOS Simulator with agent-device, used Genie to find why one tap rendered 29 components, and proved a fix that cut it to 4.

Let the agent tap the app with agent-device, and read what React rendered with Genie's react_get_renders and react_render_causes. In the Expo demo in this repo, one tap on Increment rendered 29 components, and Genie traced the extra ones to a state hook in the root App component.

The agent then moved that state down, and npx genie-react verify passed with exit code 0. The tap now renders 4 components. Every command and output below comes from one run of Genie 1.1.0 on November 19, 2026, on an iPhone 17e simulator with iOS 27.2, Expo Go 57.0.9 and React Native 0.86. Outputs are trimmed to selected fields. The full log is in the evidence file.

Connect the agent to the app

A React Native app has no dev server that hosts Genie, so you run the hub yourself. This run used port 4495 for the hub and 5241 for Metro, to stay clear of other apps on the same machine. From examples/expo-demo:

npx genie-react hub --port 4495
EXPO_PUBLIC_GENIE_URL=ws://127.0.0.1:4495/__genie/ws npx expo start --port 5241
agent-device open 'Expo Go' exp://127.0.0.1:5241 --platform ios --device 'iPhone 17e' --session upd-e

The first two commands keep running, so start each in its own terminal. Expo Go opened its developer menu over the app on first launch. A press on Continue and then on Close cleared it. Then check that Genie sees the app:

npx genie-react status --wait 15000
connected: true
ready: true
sessionId: d270f501-e559-487a-9c85-b457404b8072
app: {name:"Expo demo",reactVersion:19.2.3,reactMounted:true}

A native app has no session name. Pass the sessionId from status to every Genie command. The agent-device session keeps its own name, upd-e.

One tap renders 29 components

The demo's Increment button raises a counter, and three memoized rows show the count. Open a window, tap once, wait for the app to settle, and list the renders:

npx genie-react call react_clear_renders '{}' --session d270f501-e559-487a-9c85-b457404b8072
agent-device press 'id="increment-button"' --settle --session upd-e
npx genie-react call devtools_wait '{"condition":"settled","domains":["react","query","router"],"timeoutMs":10000}' --fail-on-result-error --session d270f501-e559-487a-9c85-b457404b8072
npx genie-react call react_get_renders '{"limit":80}' --session d270f501-e559-487a-9c85-b457404b8072 --fields name,renders,necessity,necessityReason

Trimmed to 12 of 29 rows:

[29]:
  each: {renders:1}
  - {name:App,necessity:necessary,necessityReason:dom-changed}
  - {name:Genie,necessity:unnecessary,necessityReason:inputs-unchanged}
  - {name:VisibilityTestbed,necessity:unnecessary,necessityReason:inputs-unchanged}
  - {name:VisibilityProbe,necessity:unnecessary,necessityReason:inputs-unchanged}
  - {name:FreezeScreenTestbed,necessity:unnecessary,necessityReason:inputs-unchanged}
  - {name:FrozenScreenProbe,necessity:unnecessary,necessityReason:inputs-unchanged}
  - {name:MemoNameRow,necessity:necessary,necessityReason:dom-changed}
  - {name:ToolTestbed,necessity:necessary,necessityReason:dom-changed}
  - {name:PropFixture,necessity:unnecessary,necessityReason:inputs-unchanged}
  - {name:HookFixture,necessity:necessary,necessityReason:dom-changed}
  - {name:ContextFixture,necessity:unnecessary,necessityReason:inputs-unchanged}
  - {name:QueryFixture,necessity:unnecessary,necessityReason:inputs-unchanged}

Read the coverage before you count. The same read with --select /coverage reported skippedCommitFibers: 0, budgetExhaustedCommits: 0 and inputAttributionComplete: true. Its only gap was 2 components with unresolved ownership, and the read with "appOnly":false reported complete: true with semantics: exact. This first window used the default budget. On Hermes, the adaptive window gives commits eight times the default timeLimitMs of 8 and targetTimeReserveMs of 4, and react_clear_renders reported those limits. Trimmed:

observationConfig:
  adaptive: true
  timeLimitMs: 64
  targetTimeReserveMs: 32

One tap rendered 29 components. Only the counter and the three rows show the count. ToolTestbed alone brought 19 fixture components with it, and none of them read the counter.

The rows changed on screen

The three memo rows report necessary with dom-changed. The full view of MemoNameRow shows the prop change and the native write behind that label:

npx genie-react call react_render_causes '{"component":"MemoNameRow","limit":1,"view":"full"}' --session d270f501-e559-487a-9c85-b457404b8072

Trimmed to the write list and the cause:

  MemoNameRow #10406135333024 {…,assessment:{…,behaviorEvidence:{subtreeHostMutations:{status:observed,count:1,…,writes:["#text"],callbacks:[]},…},…},…}
    ← props exact value {…,before:0,after:1,…}

agent-device saw the same change. After the tap, its diff showed Memo row: 0 change to Memo row: 1. Genie 1.0.2 labeled these rows unnecessary with output-unchanged on React Native, and 1.1.0 compares the native host props, so the label now matches the screen.

The causes point at App

npx genie-react call react_render_causes '{"component":"App","limit":1}' --session d270f501-e559-487a-9c85-b457404b8072
npx genie-react call react_render_causes '{"component":"ToolTestbed","limit":1}' --session d270f501-e559-487a-9c85-b457404b8072
npx genie-react call react_render_causes '{"component":"VisibilityTestbed","limit":1}' --session d270f501-e559-487a-9c85-b457404b8072

Trimmed to the event and cause lines, with the absolute checkout path shortened to <checkout>:

  App #10406135332873 {…,necessity:necessary,necessityReason:dom-changed,inputEvidence:changed,source:{location:<checkout>/examples/expo-demo/App.tsx:20:5,…}}
    ← state exact "state[0]"
  ToolTestbed #10406135333039 {…,necessity:necessary,necessityReason:dom-changed,inputEvidence:none-observed,source:{location:<checkout>/examples/expo-demo/App.tsx:77:9,…}}
    ← parent inferred ScrollView {origin:App}
  VisibilityTestbed #10406135332882 {…,necessity:unnecessary,necessityReason:inputs-unchanged,inputEvidence:none-observed,source:{location:<checkout>/examples/expo-demo/App.tsx:34:9,…}}
    ← parent inferred ScrollView {origin:App}

App rendered because its first useState changed. That is the counter. The testbeds had no input change. They rendered because their parent did, and origin:App names the component whose own update started it. React normally re-renders a component whenever its parent re-renders. Here is App, trimmed, with comments in place of the removed JSX:

examples/expo-demo/App.tsx
export default function App() {
  const [count, setCount] = useState(0)

  return (
    <QueryClientProvider client={queryClient}>
      {/* Genie */}
      <ScrollView>
        <VisibilityTestbed />
        <FreezeScreenTestbed />
        {/* counter card, then MemoNameRow, NamedMemoRow and ExplicitMemoRow with value={count} */}
        <ToolTestbed />
      </ScrollView>
    </QueryClientProvider>
  )
}

ToolTestbed reports dom-changed with no input change. Its child HookFixture prints its own render count, so every render of it writes new text. That write is real, but it does not make the render needed. Read the cause line next to the label.

The demo is a test fixture for Genie, not a tuned app. In your own app, state held high in the tree has the same effect.

The fix moves the state down

Move count into a component that holds only the counter card and the three rows. The demo was changed for the "after" run and then reverted. The diff, with comments in place of the moved JSX:

 export default function App() {
-  const [count, setCount] = useState(0)
-
   return (
@@
         <VisibilityTestbed />
         <FreezeScreenTestbed />
-        <View style={styles.card}>
-          {/* counter card */}
-        </View>
-        <MemoNameRow value={count} />
-        <NamedMemoRow value={count} />
-        <ExplicitMemoRow value={count} />
+        <CounterSection />
         <ToolTestbed />
@@
+function CounterSection() {
+  const [count, setCount] = useState(0)
+
+  return (
+    <>
+    <View style={styles.card}>
+      {/* counter card, unchanged */}
+    </View>
+    <MemoNameRow value={count} />
+    <NamedMemoRow value={count} />
+    <ExplicitMemoRow value={count} />
+    </>
+  )
+}

The fragment keeps the rows as direct children of the ScrollView, so the layout does not change.

Verify proves the fix

The claims say the testbeds must not render, and MemoNameRow must render, so a tap that missed the app fails. The window uses the default budget and waits on every domain:

npx genie-react verify begin --session d270f501-e559-487a-9c85-b457404b8072 --name 'press Increment' --claim 'render ToolTestbed max 0' --claim 'render VisibilityTestbed max 0' --claim 'render FreezeScreenTestbed max 0' --claim 'render MemoNameRow min 1'
agent-device press 'id="increment-button"' --settle --session upd-e
npx genie-react verify end vfy_3827dc95-5067-4548-bb86-e1ba4674c779 --session d270f501-e559-487a-9c85-b457404b8072

Before the fix, trimmed to the verdict and claim lines. The command exited with code 1:

fail vfy_3827dc95-5067-4548-bb86-e1ba4674c779 "press Increment"  3 commits, quiet after 784 ms (react, query, router, network)
  1 fail render ToolTestbed max 0  {renders:1,mounts:0,updates:1,remounts:0,semantics:exact,instances:1,activeInstances:1}
  2 fail render VisibilityTestbed max 0  {renders:1,mounts:0,updates:1,remounts:0,semantics:exact,instances:1,activeInstances:1}
  3 fail render FreezeScreenTestbed max 0  {renders:1,mounts:0,updates:1,remounts:0,semantics:exact,instances:1,activeInstances:1}
  4 pass render MemoNameRow min 1  {renders:1,mounts:0,updates:1,remounts:0,semantics:exact,instances:1,activeInstances:1}

After the fix, trimmed the same way plus the attempt line. The command exited with code 0:

pass vfy_a3b3a2bb-b9d5-4913-9be1-4c6b1bbac009 "press Increment"  3 commits, quiet after 693 ms (react, query, router, network)
  1 pass render ToolTestbed max 0  {renders:0,mounts:0,updates:0,remounts:0,semantics:exact,instances:1,activeInstances:1}
  2 pass render VisibilityTestbed max 0  {renders:0,mounts:0,updates:0,remounts:0,semantics:exact,instances:1,activeInstances:1}
  3 pass render FreezeScreenTestbed max 0  {renders:0,mounts:0,updates:0,remounts:0,semantics:exact,instances:1,activeInstances:1}
  4 pass render MemoNameRow min 1  {renders:1,mounts:0,updates:1,remounts:0,semantics:exact,instances:1,activeInstances:1}
attempt 2 for these claims on this tab; previous fail vfy_3827dc95-5067-4548-bb86-e1ba4674c779; code changed since (Fast Refresh)

Both runs reported renderCollection:available in their environment. agent-device confirmed the screen. After the tap, its diff showed the counter change from "0" to "1" and the rows change to Memo row: 1. A fresh capture of the same tap in a default window listed 4 renders: CounterSection, MemoNameRow, InnerNamedRow and CustomMemoRow, each necessary with dom-changed. Coverage was complete: true with semantics: exact.

Both runs settled on React, Query, Router and network in under a second. With Genie 1.0.2 the demo needed --domains react and a larger --budget, because its router never settled and the default budget ran out on Hermes.

When this approach does not fit

Do not read necessity alone. dom-changed says the render wrote to the screen, not that the write mattered. ToolTestbed above is dom-changed only because a fixture prints its render count. Trust the cause line, and confirm the screen with agent-device.

Check the budget before you count. The default window held on this simulator, but a larger tree can still run out. When coverage.budgetAdvice appears, clear again with its budget and repeat the action.

Genie measures development builds, so render counts here say nothing about release-build speed. For timing work, see Optimize a slow interaction. For claim syntax, see Verify a fix. For setup on Android or a physical device, see Install.

On this page