Skip to content

fix: react-cons-elem should not hoist router comp#14828

Merged
JLHwung merged 1 commit intobabel:mainfrom
JLHwung:fix-14363
Aug 4, 2022
Merged

fix: react-cons-elem should not hoist router comp#14828
JLHwung merged 1 commit intobabel:mainfrom
JLHwung:fix-14363

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Aug 4, 2022

Q                       A
Fixed Issues? Fixes #14363
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Thanks @budarin for the reproduction repo. It helps a lot. This PR is a follow-up to #14536. In this PR we set the initial value of the map HOISTED to be the jsxScope, which is the ancestry hoisting scope (if hoisted) or path.scope. Then we update HOISTED when it it actually hoisted. In this way, the Component in the test case won't be hoisted because its parent Route's hoisting scope is the BlockStatement, instead of the ArrowFunction to which we never hoisted due to no advantages.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories area: react i: regression labels Aug 4, 2022
@babel-bot
Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52674/

@JLHwung JLHwung merged commit 7fce737 into babel:main Aug 4, 2022
@JLHwung JLHwung deleted the fix-14363 branch August 4, 2022 21:28
@Nantris
Copy link
Copy Markdown

Nantris commented Aug 4, 2022

Thanks so much @JLHwung!

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Nov 4, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: react i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: After upgrading to babel-plugin-transform-react-constant-elements v7.17.6 our application has stopped working correctly

4 participants