-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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] Rewrite useContext callee #30612
Conversation
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. [ghstack-poisoned]
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. ghstack-source-id: 60120858972dacc54bfc55daaadd0924a10f2cba Pull Request resolved: #30612
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. [ghstack-poisoned]
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. ghstack-source-id: c305c4dffd4a9b794320ded734520ff35ade05db Pull Request resolved: #30612
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. [ghstack-poisoned]
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. ghstack-source-id: c305c4dffd4a9b794320ded734520ff35ade05db Pull Request resolved: #30612
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. [ghstack-poisoned]
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. ghstack-source-id: c305c4dffd4a9b794320ded734520ff35ade05db Pull Request resolved: #30612
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. [ghstack-poisoned]
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. ghstack-source-id: 0a4a3b6bbbbd4f75591f7a99a35ca23e56f6ba08 Pull Request resolved: #30612
@@ -15,7 +15,8 @@ function App() { | |||
## Code | |||
|
|||
```javascript | |||
import { c as _c } from "react/compiler-runtime"; // @enableLowerContextAccess | |||
import { useContext_withSelector } from "react-compiler-runtime"; | |||
import { c as _c } from "react/compiler-runtime"; // @lowerContextAccess | |||
function App() { | |||
const $ = _c(3); | |||
const context = useContext(MyContext); |
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.
name doesn't match the name of the generated import
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.
yeah because it's not lowered here -- note the todo in the filename
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.
i need to keep some state to check if we lower or not and propagate to the result, not sure if it's worth doing? is it an issue to have the unused imports?
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.
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. [ghstack-poisoned]
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. ghstack-source-id: 00e161b988c8f8a1cf96efff8095f050cb534cc1 Pull Request resolved: #30612
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! Looks good with the later changes to avoid imports unless they're used
If a value is specified for the LowerContextAccess environment config, we rewrite the callee from 'useContext' to the specificed value. This will allow us run an experiment internally. ghstack-source-id: 00e161b988c8f8a1cf96efff8095f050cb534cc1 Pull Request resolved: #30612
Stack from ghstack (oldest at bottom):
If a value is specified for the LowerContextAccess environment config,
we rewrite the callee from 'useContext' to the specificed value.
This will allow us run an experiment internally.