Fix constant elements hoisted before declarator (#4804)
When multiple declarators are present in a declaration, we want to insert the constant element inside the declaration rather than placing it before because it may rely on a declarator inside that same declaration.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
function render() {
|
||||
const bar = "bar", renderFoo = () => <foo bar={bar} />;
|
||||
|
||||
return renderFoo();
|
||||
}
|
||||
|
||||
function render() {
|
||||
const bar = "bar", renderFoo = () => <foo bar={bar} baz={baz} />, baz = "baz";
|
||||
|
||||
return renderFoo();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
function render() {
|
||||
const bar = "bar",
|
||||
_ref = <foo bar={bar} />,
|
||||
renderFoo = () => _ref;
|
||||
|
||||
return renderFoo();
|
||||
}
|
||||
|
||||
function render() {
|
||||
const bar = "bar",
|
||||
renderFoo = () => <foo bar={bar} baz={baz} />,
|
||||
baz = "baz";
|
||||
|
||||
return renderFoo();
|
||||
}
|
||||
Reference in New Issue
Block a user