-1

Why this work

import ActionButton from './components/atom/ActionButton'

And this not?

export ActionButton from './components/atom/ActionButton'

The line above give me the error:

Cannot find name 'ActionButton'.ts(2304)

My directory structure

.
├── components
│   ├── atom
│   │   ├── ActionButton
│   │   │   ├── ActionButton.spec.tsx
│   │   │   ├── ActionButton.stories.tsx
│   │   │   ├── ActionButton.styles.tsx
│   │   │   ├── ActionButton.tsx
│   │   │   └── index.ts

Where on index.ts I have

export { default } from './ActionButton'
Rodrigo
  • 135
  • 4
  • 45
  • 107
  • Why do you want to write `export ActionButton from './components/atom/ActionButton'`? – Heretic Monkey Sep 27 '21 at 13:31
  • Does this answer your question? [Re-export default in ES 6 modules](https://stackoverflow.com/questions/39999282/re-export-default-in-es-6-modules) – ASDFGerte Sep 27 '21 at 13:35

1 Answers1

1

Change it to export { default as ActionButton } from './components/atom/ActionButton' as ActionButton has no named export.

morganney
  • 6,566
  • 1
  • 24
  • 35
  • Is there some way to I do `export ActionButton from './components/atom/ActionButton'` or `export { ActionButton } from './components/atom/ActionButton'`? – Rodrigo Sep 27 '21 at 13:30
  • 1
    Inside ActionButton update its export to `export { ActionButton }`. Remove the default export and use a named one. – morganney Sep 27 '21 at 13:32