Skip to content

Codemod bypasses a runtime Array.map override when emitting @for #2496

Closed

Description

@domgan-oai

Expected behavior

Migrating JSX that calls rows.map(callback) preserves that method dispatch and the rendered result. When the codemod cannot preserve the call, it should leave the migration unresolved and explain why.

Reproduction

I reproduced this with the codemod built from main at 0d651902818c6011e1d86d3b52bce6739ec11b52, React 19.2.7, and Octane 0.16.7. Run the codemod with strong: true and verify: true. The result is the same with project types enabled or disabled.

export function View({ rows }: { rows: Array<{ id: string }> }) {
  return <main>{rows.map(row => <b key={row.id} data-marker="row">row</b>)}</main>;
}

A JavaScript caller supplies an ordinary array with its own method.

import { isValidElement } from 'react';

const calls = [];
const rows = [{ id: 'first' }];
Object.defineProperty(rows, 'map', {
  value(callback) {
    const element = callback(this[0], 0, this);
    calls.push(isValidElement(element));
    return [isValidElement(element) ? 'react-row' : 'foreign-row'];
  },
});

Actual behavior

  • React production SSR renders <main>react-row</main> and records [true] in calls.
  • The codemod reports a clean Strong migration and emits @for (const row of rows; key row.id). Production Octane SSR renders the <b data-marker="row">row</b> directly. The array's method never runs.
  • Both paths render the expected <b> with an unmodified array.

The receiver's Array annotation does not prove which method it uses at runtime. A preserving fallback must also account for custom methods that observe the React element passed back by the callback. The source-visible custom and sparse cases in #2484 cover a separate set of receivers.

Codex task · Host com-79386

Activity

  1. added
    bug
    agent-authored
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-authoredbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions