GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [compiler] Allow all hooks to take callbacks which access refs, but ban hooks from taking direct ref value arguments by mvitousek · Pull Request #30917 · react/react

Conversation

@mvitousek

@mvitousek mvitousek commented Sep 8, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

  • -> [compiler] Allow all hooks to take callbacks which access refs, but ban hooks from taking direct ref value arguments #30917
  • [compiler] Improve handling of refs #30902
  • [compiler] Fix issue where second argument of all functions was considered to be a ref #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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mvitousek
[compiler] Allow all hooks to take callbacks which access refs, but b…
428fcbb
…an hooks from taking direct ref value arguments

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.

[ghstack-poisoned]
@vercel

vercel Bot commented Sep 8, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 16, 2024 5:58pm
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@facebook-github-bot facebook-github-bot added the CLA Signed label Sep 8, 2024
mvitousek added a commit that referenced this pull request Sep 8, 2024
@mvitousek
[compiler] Allow all hooks to take callbacks which access refs, but b…
2ccc74e
…an hooks from taking direct ref value arguments

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.

ghstack-source-id: 1102435
Pull Request resolved: #30917
@mvitousek mvitousek mentioned this pull request Sep 8, 2024
[compiler] Allow ref access in useImperativeHandle #30913
Closed
@vercel
vercel Bot deployed to Preview September 8, 2024 18:49
View deployment
@mvitousek mvitousek mentioned this pull request Sep 8, 2024
[compiler] Improve handling of refs #30902
Merged
@mvitousek
mvitousek requested review from josephsavona and mofeiZ September 8, 2024 21:09
mvitousek
mvitousek commented Sep 8, 2024
View reviewed changes
Comment thread compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts
returnValueKind: ValueKind.Mutable,
}),
],
[

@mvitousek mvitousek Sep 8, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is left over from a previous version of this work, but seems reasonable to add anyways

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

josephsavona reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
josephsavona
josephsavona reviewed Sep 9, 2024
View reviewed changes
Comment thread ...ages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/hook-ref-callback.expect.md Outdated
```

### Eval output
(kind: exception) useRef is not defined No newline at end of file

@josephsavona josephsavona Sep 9, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
josephsavona
josephsavona approved these changes Sep 9, 2024
View reviewed changes

@josephsavona josephsavona left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mvitousek
Update on "[compiler] Allow all hooks to take callbacks which access …
a53a513
…refs, but ban hooks from taking direct ref value arguments"

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.

[ghstack-poisoned]
@mvitousek mvitousek mentioned this pull request Sep 9, 2024
[compiler] Fix issue where second argument of all functions was considered to be a ref #30912
Merged
mvitousek added a commit that referenced this pull request Sep 16, 2024
@mvitousek
[compiler] Allow all hooks to take callbacks which access refs, but b…
e78c936
…an hooks from taking direct ref value arguments

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.

ghstack-source-id: e66ce71
Pull Request resolved: #30917
@mvitousek
mvitousek merged commit a53a513 into gh/mvitousek/29/base Sep 16, 2024
@mvitousek
mvitousek deleted the gh/mvitousek/29/head branch September 16, 2024 17:57
@vercel
vercel Bot deployed to Preview September 16, 2024 17:58
View deployment
github-actions Bot pushed a commit that referenced this pull request Sep 16, 2024
@mvitousek
[compiler] Allow all hooks to take callbacks which access refs, but b…
2f4fba4
…an hooks from taking direct ref value arguments

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.

ghstack-source-id: e66ce71
Pull Request resolved: #30917

DiffTrain build for [e78c936](e78c936)
@vercel-release-bot vercel-release-bot mentioned this pull request Sep 17, 2024
Upgrade React from 206df66e-20240912 to a99d8e8d-20240916 vercel/next.js#70190
Merged
eps1lon pushed a commit to vercel/next.js that referenced this pull request Sep 18, 2024
@vercel-release-bot
Upgrade React from 206df66e-20240912 to a99d8e8d-20240916 (#70190)
5791706
**breaking change for canary users: Bumps peer dependency of React from
`19.0.0-rc-206df66e-20240912` to `19.0.0-rc-a99d8e8d-20240916`**

[diff
react/react@206df66e...a99d8e8d](react/react@206df66...a99d8e8)

<details>
<summary>React upstream changes</summary>

- react/react#30977
- react/react#30971
- react/react#30922
- react/react#30917
- react/react#30902
- react/react#30912
- react/react#30970
- react/react#30969
- react/react#30967
- react/react#30966
- react/react#30960
- react/react#30968
- react/react#30961
- react/react#28255
- react/react#30957
- react/react#30958
- react/react#30959
- react/react#30951
- react/react#30954
- react/react#30920
- react/react#30942

</details>
hanzo-dev pushed a commit to hanzoai/react that referenced this pull request Sep 9, 2026
@mvitousek
[compiler] Allow all hooks to take callbacks which access refs, but b…
3b56a2e
…an hooks from taking direct ref value arguments

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.

ghstack-source-id: e66ce71
Pull Request resolved: react#30917

This branch was successfully deployed

1 active deployment
Preview — a53a513b Deployed Sep 16, 2024 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mofeiZ mofeiZ Awaiting requested review from mofeiZ
1 more reviewer
@josephsavona josephsavona josephsavona approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

CLA Signed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mvitousek @josephsavona @facebook-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.