Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compiler]: Extend Function outlining to object methods #32039

Open
1 of 4 tasks
SimenB opened this issue Jan 10, 2025 · 1 comment
Open
1 of 4 tasks

[Compiler]: Extend Function outlining to object methods #32039

SimenB opened this issue Jan 10, 2025 · 1 comment

Comments

@SimenB
Copy link
Contributor

SimenB commented Jan 10, 2025

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/#N4Igzg9grgTgxgUxALhAgHgBwjALgAgDMoA7OXASwhPyjAQBUALCkgcwAoBKfYAHRq16AZQgBbBAAkIEANYd+g-Pgm4mEACYBGbrwHKD+GAlywahAIYAbegG59BgL4AaB8tXqNAJmT5dAXgA+PSUDY1MYc2s7N3wXWI9NAGZfYjJKaj8eRUNlcLMiaIR7UPjQxI0AFlTScioaCsqskNyjEwLLG2LYsuVHLhLHEEcgA

Repro steps

    method() {
      return false;
    },

is not hoisted, while

    method: () => {
      return false;
    },

is correctly hoisted.

Seems to be related to the fact the function is named?

This may or may not be the same as #31180?

How often does this bug happen?

Every time

What version of React are you using?

N/A

What version of React Compiler are you using?

19.0.0-beta-63e3235-20250105

@SimenB SimenB added Component: Optimizing Compiler Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug labels Jan 10, 2025
@josephsavona
Copy link
Contributor

Thanks. This isn't a bug per-se, we intentionally limited the optimization to function expressions and not object methods. But it is likely safe to extend the optimization. Note that this is unrelated to #31180

@josephsavona josephsavona added Type: Enhancement and removed Type: Bug Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels Jan 10, 2025
@josephsavona josephsavona changed the title [Compiler Bug]: Shorthand methods not hoisted out of component [Compiler]: Extend Function outlining to object methods Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants