Skip to content

[Compiler Bug]: Computed Property Names in Object Initializers #33690

@dkempner

Description

@dkempner

What kind of issue is this?

  • React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
  • babel-plugin-react-compiler (build issue installing or using the Babel plugin)
  • eslint-plugin-react-compiler (build issue installing or using the eslint plugin)
  • react-compiler-healthcheck (build issue installing or using the healthcheck script)

Link to repro

https://playground.react.dev/#N4Igzg9grgTgxgUxALhAMygOzgFwJYSYAEA5gjgAowQAOCMOAngHICGAtggBQCURwAHWJEY5WMQDkaCBAlCAvkKEIAHjQgMiGbPkJEAwhHbrMCTDl78hRInEJgctwjlU4AaqwA2UBEQC8VsI2ANpklNR0DCwc3DwAushEEgBGrDBywoqY1iJiMMQAPIbmrkQAbl4+fsB2JSrulQjyAHwAgslwBQD0xS71zQog8kA

Repro steps

function getPropertyName() {
  return 'foo'
}

export function Component() {
  const contextValue = {
    [getPropertyName()]: 'bar'
  }

  return <Context value={contextValue}>Abc</Context>
}

How often does this bug happen?

Every time

What version of React are you using?

19.1.0

What version of React Compiler are you using?

19.1.0-rc.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions