SIGN IN SIGN UP
facebook / react UNCLAIMED

The library for web and native user interfaces.

0 0 0 JavaScript

[compiler] Add hint to name variables with "Ref" suffix (#34125)

If you have a ref that the compiler doesn't know is a ref (say, a value
returned from a custom hook) and try to assign its `.current = ...`, we
currently fail with a generic error that hook return values are not
mutable. However, an assignment to `.current` specifically is a very
strong hint that the value is likely to be a ref. So in this PR, we
track the reason for the mutation and if it ends up being an error, we
use it to show an additional hint to the user. See the fixture for an
example of the message.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34125).
* #34126
* __->__ #34125
* #34124

DiffTrain build for [724b324b966343f08ff0cb16ec9d8013e3891dfd](https://github.com/facebook/react/commit/724b324b966343f08ff0cb16ec9d8013e3891dfd)
J
josephsavona committed
8ef2e214bb05d4d740b206ae406ec618776bc1a5
Parent: 52f44c7