Skip to content

Files

Latest commit

 

History

History
31 lines (23 loc) · 594 Bytes

default.md

File metadata and controls

31 lines (23 loc) · 594 Bytes

Pattern: Missing default export

Issue: -

Description

Using a default import when the imported module has no default export leads to runtime errors and makes code harder to maintain. This mismatch between import and export styles can cause unexpected behavior.

Examples

Example of incorrect code:

// ./bar.js
export function bar() {
  return null;
}

// ./foo.js
import bar from "./bar"; // No default export exists

Example of correct code:

// ./bar.js
export default function bar() {
  return null;
}

// ./foo.js
import bar from "./bar";