Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Latest commit

 

History

History
58 lines (41 loc) · 1.07 KB

jsx-no-undef.md

File metadata and controls

58 lines (41 loc) · 1.07 KB

Disallow undeclared variables in JSX (react/jsx-no-undef)

This rule helps locate potential ReferenceErrors resulting from misspellings or missing components.

Rule Details

The following patterns are considered warnings:

<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;

The following patterns are not considered warnings:

var Hello = require('./Hello');

<Hello name="John" />;

Rule Options

...
"react/jsx-no-undef": [<enabled>, { "allowGlobals": <boolean> }]
...

allowGlobals

When true the rule will consider the global scope when checking for defined Components.

The following patterns are considered okay and do not cause warnings:

var Text = require('./Text');
var Hello = React.createClass({
  render: function() {
    return <Text>Hello</Text>;
  }
});
module.exports = Hello;

When Not To Use It

If you are not using JSX then you can disable this rule.