react icon indicating copy to clipboard operation
react copied to clipboard

[Playground Bug]: Unexpected token, expected "{"

Open gkiely opened this issue 1 year ago • 2 comments

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)
  • [x] Playground issue

Link to repro

https://playground.react.dev/#N4Igzg9grgTgxgUxALhAejQAgPIAcEB2mcEBkANgpgIYEAmmUBJAti4QC4A6BGxpYDpgCiMGAEZMAXkwAKAJTSAfJgA8dAJYA3TGiUBuHnxJkhomACZpcxVJWz123UvmHeWE4JFiAzNcc6ejxGWAAqABYaYJgA7hAwANbRAGYaBAgh-KaYAMLWCsqYwJmYmDAIHLBEAc6ZAL4gdUA

Repro steps

Any component created without curly braces will create an error in the console no compiler output is shown.

See playground link.

How often does this bug happen?

Every time

What version of React are you using?

react@rc

What version of React Compiler are you using?

19.0.0-beta-8a03594-20241020

gkiely avatar Nov 21 '24 01:11 gkiely

Big

aalmanasir avatar Nov 22 '24 09:11 aalmanasir

Bug

aalmanasir avatar Nov 22 '24 09:11 aalmanasir

After my first contribution to react-compiler, I wanted to fix this too, but it seems already fixed? image

I tried to install [email protected] or 0.0.0-experimental-ba7b8e5-20241213 which is out 2 days ago and on my project arrow function with implicit return are still not optimized, do you know @josephsavona which version include this fix? or maybe there is some option to pass to reactCompilerConfig?

dimaMachina avatar Dec 15 '24 21:12 dimaMachina

ok, I found why I couldn't see optimized components with implicit returns, setting ReactCompilerConfig.compilationMode: 'all' makes them optimized

update

So I consider this as a still a bug since compilationMode: 'infer' doesn't optimize components with implicit returns

dimaMachina avatar Dec 15 '24 21:12 dimaMachina

I'm closing this because the playground error is no longer there, it doesn't optimize the arrow function components but that is a separate issue.

gkiely avatar Jan 23 '25 19:01 gkiely