Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined
JSX referenced a component that is undefined — almost always a default/named import mismatch.
Element type is invalidexpected a string (for built-in components) or a class/functionbut got: undefinedbut got: object Meaning
React renders <Foo /> by calling Foo. If the import resolved to undefined (wrong export style, wrong path, circular import), React throws this error and names the parent component.
Common causes
- import Foo from vs import { Foo } from mismatch
- Component not exported
- Circular import returning undefined
- Importing from the wrong path/index file
⚡ Quick fix
- Check how the component is exported and match the import
- console.log the imported value
- Break circular imports
Detailed fix by platform
React
- jsx
// Button.jsx: export function Button() {} import { Button } from './Button';
How to diagnose
- Component — Which render method is named?
- Import — Default or named export?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- declared and not used Go: declared and not used: x / "fmt" imported and not used
- Dynamic server usage Error: Dynamic server usage: Route /x couldn't be rendered statically because it used `cookies`
- Functions not valid as child Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render.
Most viewed in React
- React must be in scope ReferenceError: React is not defined / 'React' must be in scope when using JSX
- No QueryClient set Error: No QueryClient set, use QueryClientProvider to set one
- Functions cannot be passed Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server".
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 14 Oct 2026