Bug Report
Current Behavior
When a React component uses a let variable, hoisting of the returned React Element leads to incorrect behavior
Input Code
let foo = 'hello';
export const Component = () => {
foo = 'goodbye';
return <span>{foo}</span>;
};
Expected output
let foo = 'hello';
export const Component = () => {
foo = 'goodbye';
return React.createElement("span", null, foo);
};
Actual output
let foo = 'hello';
var _ref =
/*#__PURE__*/
React.createElement("span", null, foo);
export const Component = () => {
foo = 'goodbye';
// renders "hello" instead of "goodbye"
return _ref;
};
Bug Report
Current Behavior
When a React component uses a
letvariable, hoisting of the returned React Element leads to incorrect behaviorInput Code
https://babeljs.io/repl#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=DYUwLgBAZg9jEF4IHIAWJjBsg3AKDxAA8AHGAJ0gGMYA7AZ0jHIEsBzNkc-gQSrBZ16ANRYBDAEIBXMGDqIIACgCUiAHwQA3ngjQ4C5GzgATAEYBPELh0Ry4KeVoQAPPRJjaazbBgBfZwD0bh5q-L74QA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=false&presets=react&prettier=false&targets=&version=7.6.2&externalPlugins=%40babel%2Fplugin-transform-react-constant-elements%407.6.0
Expected output
Actual output