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.
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
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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
toJSX.Element
toReactNode
toReactChild
toFunctionComponent
to even removing it altogether, and it just flat out refuses to get rid of that error message.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'
toimport { MyComponent } from '@gavinsykes/my-component
fixed it! 😁