Skip to content

[Compiler Bug]: startTransition shouldn't be required as a dependency for useCallback. #34748

@cpojer

Description

@cpojer

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/#N4Igzg9grgTgxgUxALhAgHgBwjALgAgBMEAzAQygBsCSoA7OXASwjvwCUFswnccBPAMJkYhABTAAOm3wwuEHnxj9ks+YoEBpBPwA00-PgBuTBAHcEMVSfOXte6QF9VUmXO68Bqzh6VCRhAD67gqeygAkANY6ANwGxqYWVhzqYf6igTZJUbFOAJT4roZwrGAEANq6+GUiuAAqMGR0iix0ALr4ALz4UGAIDU0trGJ5cTIlzQRyJAi4cAAWnCRdPX1L+AA8KTNz8wBSEABGADJMZQBibAA++HRUlPgAfPhid5SUo-ETZWq+Aiu9BDnRoAcwAtgg6LgxPFDCDGph5gBHSgAA1hhnwJFBEKhKT+ymEGRCGmU+FY+NCfkKGMx+CYhFpmMoEDgZEoCDATMMcjIhH4AGVcGRcAhudVhbhetJxQA6eU+KkCAASCD5lmCqT8cvlBxOZ1wmoJ-HwAAERCCoLjcGAxCV6LhVABGAAMeSZjgxqP0Mh5Wq0Oh9hk+dC+pQqfMIitJ-GOrPZCCqkejaTjbI5AEkwBm6OdKEwQfNcB1OhjAQBZKCS1qbSkxomEACChCj-uUaYTlerFOeYnhZERKPRvsxYKrIprKb8DebreNHY5XYnw3F4RJaVUGYAIgBCVcs9MIVRCmBMOggvcj4M0q+Y5Nt2Pxjlidd+VRrh9VA8J9-fjkFIo6SA+VZSnAQGyNJVlHFT1b1gulURDMNJnJOhZzA9snwQAE+mEd5DjIOBIhhEcxD-I8JVPc8Ck6Z5ALpJhljEHd73nLCsxzPMCyLADxVYqDH0PCRxUMVhBAgMFMA5UVCFUEYujokTMRqPABmaXhWjEeTaJvIC9MxaZZgWJZZTgWA5ChAB+WVhNvfTMXtKFnRdIN7P0syYEgZI3koVy3MxRwQ38wxArGfzHD8-SjBEJgyEODkwBcJTDHIyL7NfLxfgE2UGTSoCIpgoL8oxAqR3KJl+JjBdEwqlsMMEhMONzfNC1wPKMuUHLCEitpXKQtxZlgNhWHQh9qrGWCQF0EAJhIAsUBAJhJJwAhcH4TBsOAfAAAVKCgEEzwAeUwZhSnwRwsRgCT8AAcgIw4EEoABaKT9rPJ7eUYJ6SkkpgORgAB6QgDRusZpFswwAYBn7MD+5c6HLCBiFUSQQHZShUfiSETCuuhrSS0MR0hOKOW2uQ+hgIwEAAUXQA0zxBcsEDBCAmAAL3hgBxKARCaUVOVUXAYCgGqR2i-NCBFBAyc5Swqdp+nzyZln2a5nnGihBABfwIWRfiWCLrACcwDmzkdtqWLKA2Xa3roY7TuaR5Rim8B5ggMwc1FGA6HZMAUHISg+kcIA

Repro steps

When using:

const [, startTransition] = useTransition();

And then making use of the startTransition call in a useCallback, the React Compiler will say that it cannot preserve manual memoization. Once startTransition is added to the dependencies array, the React Compiler is happy. Since useTransition comes from React, and the exhaustive deps rule does not ask to add startTransition to the deps array, the React Compiler should assume this reference is stable.

How often does this bug happen?

Every time

What version of React are you using?

latest

What version of React Compiler are you using?

latest

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