DEV Community

Discussion on: Create a React component library with Vite and Typescript

Collapse
 
rafaelnogueira profile image
Rafael Nogueira

Thanks for this article, it was very helpfull.
I have a problem when use the component in my project. It show: TypeError: s.button is not a function
It seems to happen in one of the modules

Call Stack
<unknown>
dist/vfb-components.es.js
Enter fullscreen mode Exit fullscreen mode

It looks like a problem with the style file or with the imported styled from styled-components.
This only happens when a install the library at NextJS project. It works fine with CRA.

Any ideia how to fix this?

Collapse
 
nicolaserny profile image
Nicolas Erny

Hard to investigate. I use this strategy with Nextjs on some projects without any trouble: component library with Vite + webapp in Nextjs. Do you have a public github repository with this issue?

Collapse
 
rafaelnogueira profile image
Rafael Nogueira

So i found a topic about this problem. It only happens with projects using SSR.
There's no official fix for this at the moment, but this fix works github.com/styled-components/style...

Collapse
 
nicolaserny profile image
Nicolas Erny

Thanks for sharing.