DEV Community

Discussion on: How to Create and Publish a React Component Library

Collapse
 
gavinsykes profile image
Gavin Sykes • Edited

Thanks for this Alex, it's been incredibly helpful and encouraged me to finnaly take the plunge and stop using webpack to (badly) bundle my components and libraries together!

One issue I am facing though, which I'm hoping someone has encountered and fixed before, is that when I try and import the main component from my package into another project, TypeScript then shouts at me "JSX element type 'YourComponent' does not have any construct or call signatures. ts(2604)". Like, what?

I've tried changing the return type from ReactElement to JSX.Element to ReactNode to ReactChild to FunctionComponent to even removing it altogether, and it just flat out refuses to get rid of that error message.

Collapse
 
gavinsykes profile image
Gavin Sykes

False alarm!

My component wasn't set as a default import (so I'm going to look at doing that) so changing import MyComponent from '@gavinsykes/my-component' to import { MyComponent } from '@gavinsykes/my-component fixed it! 😁

Some comments have been hidden by the post's author - find out more