create-react-library icon indicating copy to clipboard operation
create-react-library copied to clipboard

Unable to destructure exported components

Open jfacoustic opened this issue 5 years ago • 0 comments

When importing components from my library, I have to import the entire package.

Is this the normal behaviour create-react-library, an issue with my code, or a bug?

This works:

...

import Kit from 'my-ui-kit';
...

function App = () => {
  return <Kit.CoolComponent />
}

But not

...

import { CoolComponent } from 'my-ui-kit'

function App = () => {
  return <CoolComponent/>
}

Here's the error I get:

Attempted import error: 'CoolComponent' is not exported from 'my-ui-kit'.

dist/index.modern.js is clearly exporting the component:

...

var index = {
  CoolComponent: CoolComponent
}

export default index

jfacoustic avatar Oct 07 '20 18:10 jfacoustic