October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Fix the React Component Not Defined Error

The “ComponentName is not defined” error means JavaScript cannot see the identifier where JSX uses it. Check spelling, exports and imports, JSX capitalization, and scope in that order.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The message ComponentName is not defined, usually shown as ReferenceError: ComponentName is not defined, means JavaScript tried to read an identifier that has no binding in the scope where that code runs. React does not invent this error. When JSX such as <ComponentName /> is compiled, it becomes a reference to a variable named ComponentName, and if the file cannot see that variable, the engine throws a ReferenceError. In most cases the fix is one of four things: the name is misspelled, the component is not imported, the import syntax does not match the export, or the declaration exists somewhere the rendering code cannot reach.

Start with the exact identifier in the error

Open the browser console or the terminal output and copy the name before the words “is not defined.” That string is the only identifier the engine is complaining about. Compare it character by character with the JSX tag that renders it and with the declaration or import that should provide it. A single letter difference, a singular and plural mismatch, or a component that was renamed in one file but not the other will each produce this exact message.

Per MDN’s guide to this error, a ReferenceError of this kind is raised when code refers to a variable that does not exist, or to one that is not accessible from where the reference happens. The message tells you the name; the rest of the diagnosis is about why the name is not visible at that point.

Diagnostic path, in order

Work through these checks in sequence. Each one rules out a category of cause, and the first check that fails is usually the fix.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

1. Confirm the spelling and capitalization in both places

Search the project for the identifier and compare the declaration (or the import line) with the JSX tag. Profile, profile, and Profiles are three different names. Use your editor’s find feature with case sensitivity turned on to catch mismatches.

2. Decide whether the component lives in the same file or another module

If the component is declared in the same file, make sure the declaration is at the module’s top level or in a scope that encloses the JSX. If it lives in another file, it must be exported there and imported where it is rendered. React’s documentation demonstrates this exact pattern of moving a component to its own file, exporting it, and importing it into the file that uses it. See React’s guide to importing and exporting components.

3. Match the import syntax to the export syntax

The export form in the defining file determines the import form in the rendering file. The mismatch is a common reason a correctly named component still appears as undefined.

Export in the defining file Import in the rendering file Notes
export default function Profile() { … } import Profile from './Profile.js'; No braces. The local name can differ from the function name, but matching it makes debugging easier.
export function Profile() { … } import { Profile } from './Profile.js'; Braces are required. The name inside the braces must match the exported name exactly.

A complete default-export pair looks like this:

// Profile.js
export default function Profile() {
  return <p>Profile</p>;
}

// App.js
import Profile from './Profile.js';

export default function App() {
  return <Profile />;
}

If the same file used export function Profile(), the import in App.js would have to be import { Profile } from './Profile.js';. Mixing the two forms is the most frequent cause of this error when the spelling looks correct.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Check JSX capitalization

React treats JSX tags differently depending on case. The React Learn guide on your first component states the rule directly: “React components are regular JavaScript functions, but their names must start with a capital letter or they won’t work!” A capitalized tag such as <Profile /> refers to a binding named Profile. A lowercase tag such as <profile /> is treated as a built-in HTML element, so it does not look up a variable at all. That means a lowercase tag usually produces no ReferenceError; the component simply never renders, and the page shows an unrecognized element instead. Keep component names capitalized in both the declaration and the tag. (Source: React — Your First Component.)

5. Look for a declaration that is out of scope

If spelling, export, import, and capitalization are all correct, the binding may be declared inside another function or block. Variables declared with let and const are block-scoped, and a local function’s variables cannot be read from outside that function. MDN’s JavaScript reference documents this lexical scoping behavior. A component defined inside another component is a common trigger:

function Header() {
  const Logo = () => <img src="logo.svg" alt="" />;
  return <div><Logo /></div>;
}

function Page() {
  return <Logo />; // ReferenceError: Logo is not defined
}

The fix is to move Logo to the module’s top level, export it if another file needs it, and import it where it is used. If the same markup is needed in several places, a separate module is the cleanest home for it. Passing a value through props is the right tool for data, but a component that is simply missing from scope should be declared where it can be reached.

MDN’s ReferenceError page is the primary reference for the error itself: ReferenceError: “x” is not defined.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

6. Re-run in a development build and follow the next error

Fix one suspected cause at a time, then reload. The first error that changes is your next clue. For local debugging, use the development build of React rather than the production bundle, because it includes additional debug information and warnings. React’s error reference page describes this for its minified production errors; that page covers a different minified error, so treat it as general guidance rather than a diagnosis of this message: React — Minified React error #252.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Quick reference: symptom, likely cause, and where to look

What you see Most likely cause Step to follow
ComponentName is not defined with a name that differs from a declaration by case or letters Misspelling or inconsistent capitalization Step 1
Same error for a component defined in another file Missing export or missing import Step 2
Same error after the export and import both look right Default and named import syntax swapped Step 3
Component does not appear, and no ReferenceError is shown Lowercase JSX tag rendering as an HTML element Step 4
Same error for a component declared inside another function or block Declaration out of scope Step 5

What this error does not tell you

The error names the missing identifier but not the file that should have provided it, so the search has to be manual. Public documentation from React and MDN establishes the causes and the fixes described above; it does not provide a measured frequency for this error, so it is not possible to say how often each cause occurs in real projects. The diagnostic order above follows the code path from name, to module boundary, to scope, which is the sequence that narrows down the cause most quickly.

The steps here apply to standard React and JavaScript module syntax. Build tools and frameworks can add their own import resolution rules, so if a correct-looking import still fails, check your framework’s documentation for its module resolution behavior alongside the official React guides.

Once the identifier is visible in the file that renders it, the error disappears. If a different error appears next, it has its own cause and should be diagnosed from its own message.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Also check whether the spelling in the error matches the spelling in your import, because a renamed component is easy to miss when the rename happened in another file.

“

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.