0

I have noticed that some file structures follow the pattern like:

/component
-Button

  • index.js
  • Button.js
  • button.module.css

Normally what I see is the following:

in Button.js

const Button = () => {...} 
export default Button

in index.js

export {default} from './Button'

Why that export in index.js looks like a named export. My Button component was exported as a default.

Is VS code doing and auto import where my component goes from default export to named export? Or is this a React thing? ES6?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Marco
  • 11
  • 3
  • It's so someone can import the component using `path/to/button` instead of `path/to/button/Button.js` – evolutionxbox Nov 17 '21 at 12:16
  • 1
    It's an ES6 module thing, it just means export the default from "./Button" as the default from this whole module: https://stackoverflow.com/a/59002206/3001761, https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export – jonrsharpe Nov 17 '21 at 12:17

0 Answers0