💼 This rule is enabled in the ☑️ recommended config.
This rule helps locate potential ReferenceErrors resulting from misspellings or missing components.
Examples of incorrect code for this rule:
<Hello name="John" />;// will ignore Text in the global scope and warn
var Hello = React.createClass({
render: function() {
return <Text>Hello</Text>;
}
});
module.exports = Hello;Examples of correct code for this rule:
var Hello = require('./Hello');
<Hello name="John" />;...
"react/jsx-no-undef": [<enabled>, { "allowGlobals": <boolean> }]
...When true the rule will consider the global scope when checking for defined Components.
Examples of correct code for this rule, when "allowGlobals" is true:
var Text = require('./Text');
var Hello = React.createClass({
render: function() {
return <Text>Hello</Text>;
}
});
module.exports = Hello;It's recommended to avoid this rule if your project:
- does not use JSX
- uses TypeScript, which automatically enables better checks than ESLint
no-undefrules - uses
typescript-eslintwithno-undef