logoESLint React
Rules

jsx-no-undef

Full Name in eslint-plugin-react-x

react-x/jsx-no-undef

Full Name in @eslint-react/eslint-plugin

@eslint-react/jsx-no-undef

Description

This rule is used to prevent the use of undefined variables in JSX. It checks for any undefined variables in the JSX code and reports them as errors.

Examples

Failing

import React from "react";
 
const button = <MyButton />;
//              ^^^^^^^^
//              - 'MyButton' is not defined

Passing

import React from "react";
import MyButton from "./MyButton";
 
const button = <MyButton />;

Implementation

On this page