React received an invalid component type that is neither a string (built-in HTML element) nor a function/class (custom component). This typically happens when components are incorrectly imported, not exported, or defined as invalid values.
This error occurs when React's JSX transpiler tries to render something that isn't a valid React component. React components must be one of two types: 1. Built-in components represented as lowercase strings: "div", "span", "button", etc. 2. Custom components defined as functions or classes: MyComponent, MyClass, etc. When React encounters an object, undefined, null, or other invalid type in the JSX, it throws this invariant violation. This is a fundamental validation that prevents React from attempting to render invalid structures. The error message indicates React's type checking failed at the point of rendering, which means your JSX is referencing something that isn't a proper component.
Verify that components exported as default are imported without curly braces, and named exports use curly braces.
Default export:
// Correct
import MyComponent from './MyComponent';Named export:
// Correct
import { MyComponent } from './MyComponent';
// Wrong - will be undefined
import MyComponent from './MyComponent';If you've mixed up the import style, the imported value will be undefined, triggering this error.
Check that the file where the component is defined actually exports it. Common issues:
Exported as default but importing as named:
// MyComponent.jsx - exports as default
export default function MyComponent() {
return <div>Hello</div>;
}
// App.jsx - wrong import syntax
import { MyComponent } from './MyComponent'; // ERRORExported as named but importing as default:
// MyComponent.jsx - exports as named
export function MyComponent() {
return <div>Hello</div>;
}
// App.jsx - wrong import syntax
import MyComponent from './MyComponent'; // ERRORFix by matching the export type with the import syntax.
Even a small typo in the import path will cause the component to be undefined.
// Wrong - typo in filename
import Button from './components/Botton'; // File is actually Button.jsx
// Correct
import Button from './components/Button';Use your IDE's autocomplete or search to verify file names match exactly (case-sensitive on Linux/Mac).
Components must be functions (functional components) or classes (class components), not plain variables.
Wrong - component as variable:
const MyComponent = <div>Hello</div>; // This is JSX, not a component
function App() {
return <MyComponent />; // ERROR - MyComponent is not a function
}Correct - component as function:
function MyComponent() {
return <div>Hello</div>;
}
function App() {
return <MyComponent />;
}Components must be callable (functions/classes) so React can invoke them during rendering.
Add logging before the problematic render to see what value React is receiving:
import MyComponent from './MyComponent';
console.log('MyComponent value:', MyComponent); // Check if undefined or an object
function App() {
return <MyComponent />;
}If the console shows undefined, the import failed. If it shows an object (like { default: function }), you likely have a default/named import mismatch.
Circular dependencies can cause imported values to be undefined.
Example circular dependency:
// A.jsx
import B from './B';
export default function A() {
return <B />;
}
// B.jsx
import A from './A'; // Circular!
export default function B() {
return <A />;
}Refactor to break the cycle by extracting shared code into a third module:
// Shared.jsx
export function sharedLogic() { }
// A.jsx
import B from './B';
import { sharedLogic } from './Shared';
// B.jsx
import { sharedLogic } from './Shared'; // No circular dependencyThis error can appear in production even if development works fine due to module bundling differences. Minified React messages may show this error without the full explanation.
When using third-party component libraries, ensure you're importing from the correct entry point. For example, some libraries export differently for ESM vs CommonJS. Also check that peer dependencies (like the library version of React) match your application version.
If using Redux or context providers, verify the Provider is wrapping components correctly and that selectors/hooks are returning valid components, not plain values.
For React Router, make sure to import Link from 'react-router-dom' not from 'react-router' to avoid this error.
Prop spreading could cause security issues
Prop spreading could cause security issues
Error: error:0308010C:digital envelope routines::unsupported
Error: error:0308010C:digital envelope routines::unsupported
React Hook "useEffect" is called conditionally. React Hooks must be called in the exact same order in every component render.
React Hook useEffect placed inside a condition
Hook can only be called inside the body of a function component
Hook can only be called inside the body of a function component
Rollup failed to resolve import during build
How to fix "Rollup failed to resolve import" in React