ReferenceError: Component is not defined
Error message
Component is not defined
Quick summary
You referenced a component in JSX but it was never imported or declared, so JavaScript doesn't know what it is.
Why this happens
Forgot to import the component at the top of the file
Typo in the component name (case-sensitive —
MyComponentvsmyComponent)The component is exported from a different module but not imported here
Default vs named export mismatch
Minimal example
// Missing import
function App() {
return <Header />; // Header is not defined
}import Header from "./Header";
function App() {
return <Header />;
}Header is used but never imported. Adding the import statement at the top fixes the ReferenceError.
How to diagnose
Check the import statement at the top of the file
Verify the component name matches the import exactly (case-sensitive)
Check whether the file uses
export defaultor namedexportLook at the browser console for the exact undefined name
How to fix
Add an import statement:
import MyComponent from './MyComponent'Fix the typo to match the exact component name
Use the correct import syntax for default vs named exports
How to prevent
Use an IDE with auto-import features
Enable ESLint with react/jsx-no-undef rule
Use consistent naming conventions (PascalCase for components)
Related Resources
Related Glossary
Related Lessons
- Components
Learn how to create and import components.