Variable only used in React component name is minified away.
See original GitHub issueWhen a variable is only used in React components it can’t find them and minify’s them away causing the code to break.
This issue is also in Eslint reporting 'components' is defined but never used at line 4 col 7
with the ‘no-unused-vars’ rule enabled.
Input:
'use strict';
function test() {
var components = window.foo.bar;
return <components.baz/>;
};
test();
Output:
'use strict';function test(){return window.foo.bar,React.createElement(components.baz,null)};test();
Related ESLint issue: https://github.com/eslint/eslint/issues/7418
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
React / JSX Dynamic Component Name - Stack Overflow
Keep in mind that your variable should hold the component itself and not just the name of the component as a string. –...
Read more >JSX In Depth - React
Capitalized types indicate that the JSX tag is referring to a React component. These tags get compiled into a direct reference to the...
Read more >How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
Learn how to use Rollup as a smaller, more efficient alternative to webpack and Browserify to bundle JavaScript files in this step-by-step tutorial...
Read more >How To Set Up a React Project with Create React App
Starting a new React project used to be a complicated multi-step process that involved setting up a build system, a code transpiler to...
Read more >Advanced Features: Next.js Compiler
v12.1.0, Added support for Styled Components, Jest, Relay, Remove React ... SWC can be used for compilation, minification, bundling, and more – and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@boopathi that sounds counter-intuitive, let’s just change it?
Actually, upon closer examination I see that it works correctly on master with
passPerPreset
.