-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Don't hoist JSX elements referencing mutable variables (#13054)
issue-13051 Co-authored-by: Clint Goodman <clintgoodman@workfront.com>
- Loading branch information
Showing
6 changed files
with
28 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...ransform-react-constant-elements/test/fixtures/constant-elements/deopt-mutable/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
var _span; | ||
|
||
let foo = 'hello'; | ||
export const Component = () => { | ||
foo = 'goodbye'; | ||
return _span || (_span = <span>{foo}</span>); | ||
return <span>{foo}</span>; | ||
}; |
10 changes: 10 additions & 0 deletions
10
...lugin-transform-react-constant-elements/test/fixtures/constant-elements/for-loop/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function render() { | ||
const nodes = []; | ||
|
||
for(let i = 0; i < 5; i++) { | ||
nodes.push(<div>{i}</div>) | ||
} | ||
|
||
return nodes; | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
...ugin-transform-react-constant-elements/test/fixtures/constant-elements/for-loop/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function render() { | ||
const nodes = []; | ||
|
||
for (let i = 0; i < 5; i++) { | ||
nodes.push(<div>{i}</div>); | ||
} | ||
|
||
return nodes; | ||
} | ||
|
4 changes: 1 addition & 3 deletions
4
...nsform-react-constant-elements/test/fixtures/constant-elements/global-reference/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
var _div; | ||
|
||
var Foo = React.createClass({ | ||
render: function render() { | ||
return _div || (_div = <div foo={notDeclared}></div>); | ||
return <div foo={notDeclared}></div>; | ||
} | ||
}); |