score:1

Accepted answer

I appear to have got it working although doesn't seem quite right. I had to install core-js into the library package and then change the import to be the path to the component I want within the dist folder, e.g.

import { SayHello} from 'devso-react-library/dist/components/SayHello'

score:0

You are not exporting components as a default but in index.js you are importing as default.

You can avoid the extra step of import and export from the index.js. You can directly export components without importing them into index.js

// Component
import * as React from 'react';
export const SayHello = (props) => {
    return (
        <h1>Hello ${props.name}</h1>
    )
}

// index.js
export * from "./components/SayHello";
     OR
export { SayHello } from "./components/SayHello";

score:1

Post your package.json and check if you have something like this pointing to your types.

enter image description here

For quick testing I recommend you to use link.

In your library do (with yarn):

  • yarn link
  • yarn install
  • cd node_modules/react
  • yarn link
  • cd node_modules/react-dom
  • yarn link

Then in the project you need to use the library

  • yarn link react
  • yarn link react-dom
  • yarn link

Related Query

More Query from same tag