react icon indicating copy to clipboard operation
react copied to clipboard

[compiler] Allow all hooks to take callbacks which access refs, but ban hooks from taking direct ref value arguments

Open mvitousek opened this issue 5 months ago • 1 comments

Stack from ghstack (oldest at bottom):

  • -> #30917
  • #30902
  • #30912

Summary: This brings the behavior of ref mutation within hook callbacks into alignment with the behavior of global mutations--that is, we allow all hooks to take callbacks that may mutate a ref. This is potentially unsafe if the hook eagerly calls its callback, but the alternative is excessively limiting (and inconsistent with other enforcement).

This also bans directly passing a ref.current value to a hook, which was previously allowed.

mvitousek avatar Sep 08 '24 18:09 mvitousek