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 Bug]: False positive Ref values (the current property) may not be accessed during render for non-jsx code #31637

Open
4 tasks
dimaMachina opened this issue Nov 26, 2024 · 1 comment
Labels
Component: Optimizing Compiler Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug

Comments

@dimaMachina
Copy link

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/#N4Igzg9grgTgxgUxALhAHRFMCAEcA2AlggHYAuGA3GiTYQLYAOEMZOwOAVmAB44C+OAGYwI9HBhgIAhnDIB6bjwC0MKOQYIqdJizYcsCAEoIhA4aPGSZc7STgQSYNgGEI+fNMbYcAXhwAFMA0OHgAFoT4ACZStCT8AJR+AHzsIXiOzhnk0oQkCDAmZv6GRQEkUB4J1CShUmSwtfIAVDgAAgD6HQAKAKpGAKJdOM2KvAEYUYQAbhgANGm1oThSQsjZZLn5haZz6aFwEdGx6Yk1-DUIPMys7DhuHl4+FyD8QA

Repro steps

following code gives false positive error

const Collapse = ({
  children
}) => {
  const containerRef = useRef(null);
  return /* @__PURE__ */jsx("div", {
    ref: containerRef,
    children
  });
};

but not

export const Collapse: FC<{
  children: ReactNode
}> = ({ children }) => {
  const containerRef = useRef<HTMLDivElement>(null!)

  return <div ref={containerRef}>{children}</div>
}

How often does this bug happen?

Every time

What version of React are you using?

from playground

What version of React Compiler are you using?

from playground

@dimaMachina dimaMachina added Component: Optimizing Compiler Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug labels Nov 26, 2024
@gsathya
Copy link
Contributor

gsathya commented Dec 2, 2024

The react compiler needs to run on the original source, not transformed code. There is some support forjsx calls, but it's not recommended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Optimizing Compiler Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants