Skip to content

codemod: keyed map lowering can evaluate the key before JSX props and children #2456

Closed

Description

@domgan-oai

Reproduction

Run the codemod with project types and Strong verification on this React module. Build the original with esbuild's automatic React JSX runtime and run both outputs in production SSR.

import { useId } from 'react';

function Cell({ before, after, children }: {
  before: string;
  after: string;
  children: React.ReactNode;
}) {
  const id = useId();
  return <span id={id} data-before={before} data-after={after}>{children}</span>;
}

export function List({ rows }: {
  rows: { id: string; attr(): string; child(): string }[];
}) {
  return <div>{rows.map(row =>
    <Cell before={row.attr()} key={row.id} after={row.attr()}>{row.child()}</Cell>
  )}</div>;
}

Pass these props to each renderer with a fresh marker.

let marker = '-';
const rows = ['a', 'b'].map(id => ({
  get id() { marker = id; return id; },
  attr() { return marker; },
  child() { return marker; },
}));

Observed

React evaluates the props and child before the separate key argument in each callback. The first span has data-before="-" and text -. The codemod emits a clean Strong @for, whose header reads the key first. The first span has data-before="a" and text a.

Verified with the codemod source at 6cdbc952c, Octane 0.16.7 and React and React DOM 19.2.7. The callback has no setup statements, so the setup check in #2453 does not cover this case.

Expected

Preserve the observable order of key, prop and child evaluation when rewriting the map. Keep the list in compatibility mode where the transform cannot preserve that order.

Activity

  1. added
    bug
    agent-authored
    on Nov 11, 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