Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Minified React error 130 in a production build

ErrorMinified React error #130

Short answer

Error 130 is React's message that an element type is invalid: it expected a string or a component but got something else, often undefined. The cause is most often an import that does not match its export, or a lazy import without a default export. Match the import style to the export.

  • Applies to React 19, Vite 6, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find which component receives undefined. Run the development build, where React prints the full message and a component stack, then check what each import resolves to.

    npm run dev
  2. 2Match what you see, then jump to its fix

    1. 1The full development message names the bad value, often undefined; it appears right after you added or renamed an importA default import for a named export, or the reverseFix
    2. 2The failure appears only when the lazy component first renders, and the file has a named export onlyReact.lazy points at a module without a default exportFix

What does the error look like?

  • Minified React error #130
  • Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got:

Cause 1 of 2

A default import for a named export, or the reverse

1Check

A default export is imported without braces and a named export with braces. Using the wrong one gives you undefined, and React then has nothing to render. Print what the import really is.

import * as Mod from './Button';
console.log(Object.keys(Mod)); // is the component under 'default' or a name?

2Fix

Use the import form that matches the export.

// Button.js has: export default function Button() {}
import Button from './Button';

// Button.js has: export function Button() {}
import { Button } from './Button';

3Verify

Rebuild and load the page that failed; the component renders.

npm run build && npm run preview

Confirmed by react.dev

Did this fix it?

Cause 2 of 2

React.lazy points at a module without a default export

1Check

The function you give to lazy must resolve to an object whose default property is the component. A module with only named exports has no default.

grep -n "export" src/components/Chart.js

2Fix

Add a default export, or map the named export to default inside the lazy call.

const Chart = lazy(() =>
  import('./Chart.js').then(m => ({ default: m.Chart }))
);

3Verify

Render the lazy component inside Suspense and confirm it loads.

npm run build && npm run preview

Confirmed by react.dev

Did this fix it?

How do I stop it coming back?

  • Pick one export style per project (named or default) and keep to it.
  • Run the production build in CI and open one page, so a minified error appears before release.
  • Give each component a file name equal to its export name.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.