Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allowMutablePropsOnTags
: cache JSX const elements w/ fn props (#12975)
- Loading branch information
1 parent
2de3f1c
commit 300e477
Showing
26 changed files
with
157 additions
and
116 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
...m-react-constant-elements/test/fixtures/allowMutablePropsOnTags/function-closure/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,3 @@ | ||
function Component({ increment }) { | ||
return () => <Counter onClick={value => value + increment} />; | ||
} |
9 changes: 9 additions & 0 deletions
9
...act-constant-elements/test/fixtures/allowMutablePropsOnTags/function-closure/options.json
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,9 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"transform-react-constant-elements", | ||
{ "allowMutablePropsOnTags": ["Counter"] } | ||
], | ||
"syntax-jsx" | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
...-react-constant-elements/test/fixtures/allowMutablePropsOnTags/function-closure/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,7 @@ | ||
function Component({ | ||
increment | ||
}) { | ||
var _Counter; | ||
|
||
return () => _Counter || (_Counter = <Counter onClick={value => value + increment} />); | ||
} |
3 changes: 3 additions & 0 deletions
3
...act-constant-elements/test/fixtures/allowMutablePropsOnTags/function-impure-body/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,3 @@ | ||
function Component() { | ||
return () => <Counter onClick={value => value + prompt("Increment:")} />; | ||
} |
9 changes: 9 additions & 0 deletions
9
...constant-elements/test/fixtures/allowMutablePropsOnTags/function-impure-body/options.json
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,9 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"transform-react-constant-elements", | ||
{ "allowMutablePropsOnTags": ["Counter"] } | ||
], | ||
"syntax-jsx" | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
...ct-constant-elements/test/fixtures/allowMutablePropsOnTags/function-impure-body/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,5 @@ | ||
var _Counter; | ||
|
||
function Component() { | ||
return () => _Counter || (_Counter = <Counter onClick={value => value + prompt("Increment:")} />); | ||
} |
3 changes: 3 additions & 0 deletions
3
...nstant-elements/test/fixtures/allowMutablePropsOnTags/function-same-binding-name/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,3 @@ | ||
function Component({ value }) { | ||
return () => <Counter onClick={value => value + 1} />; | ||
} |
9 changes: 9 additions & 0 deletions
9
...nt-elements/test/fixtures/allowMutablePropsOnTags/function-same-binding-name/options.json
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,9 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"transform-react-constant-elements", | ||
{ "allowMutablePropsOnTags": ["Counter"] } | ||
], | ||
"syntax-jsx" | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
...stant-elements/test/fixtures/allowMutablePropsOnTags/function-same-binding-name/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,7 @@ | ||
var _Counter; | ||
|
||
function Component({ | ||
value | ||
}) { | ||
return () => _Counter || (_Counter = <Counter onClick={value => value + 1} />); | ||
} |
3 changes: 3 additions & 0 deletions
3
...transform-react-constant-elements/test/fixtures/allowMutablePropsOnTags/function/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,3 @@ | ||
function Component() { | ||
return () => <Counter onClick={value => value + 1} />; | ||
} |
9 changes: 9 additions & 0 deletions
9
...sform-react-constant-elements/test/fixtures/allowMutablePropsOnTags/function/options.json
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,9 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"transform-react-constant-elements", | ||
{ "allowMutablePropsOnTags": ["Counter"] } | ||
], | ||
"syntax-jsx" | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
...ransform-react-constant-elements/test/fixtures/allowMutablePropsOnTags/function/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,5 @@ | ||
var _Counter; | ||
|
||
function Component() { | ||
return () => _Counter || (_Counter = <Counter onClick={value => value + 1} />); | ||
} |
3 changes: 3 additions & 0 deletions
3
...gin-transform-react-constant-elements/test/fixtures/allowMutablePropsOnTags/iife/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,3 @@ | ||
function Component() { | ||
return () => <Counter init={(value => value + prompt("Increment:"))(2)} />; | ||
} |
9 changes: 9 additions & 0 deletions
9
...transform-react-constant-elements/test/fixtures/allowMutablePropsOnTags/iife/options.json
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,9 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"transform-react-constant-elements", | ||
{ "allowMutablePropsOnTags": ["Counter"] } | ||
], | ||
"syntax-jsx" | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
...in-transform-react-constant-elements/test/fixtures/allowMutablePropsOnTags/iife/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,3 @@ | ||
function Component() { | ||
return () => <Counter init={(value => value + prompt("Increment:"))(2)} />; | ||
} |
4 changes: 2 additions & 2 deletions
4
.../pure-expression-whitelist-deopt/input.js → ...ePropsOnTags/not-allowed-element/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
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...pure-expression-whitelist-deopt/output.js → ...PropsOnTags/not-allowed-element/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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
|
@@ -7,4 +7,3 @@ function render() { | |
|
||
return nodes; | ||
} | ||
|