DEV Community

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

Collapse
 
alexeagleson profile image
Alex Eagleson

In the "Adding Tests" section there is an instruction for editing your jest config to use jsdom instead of React DOM which is aimed to eliminate the need for that dependency, did you include that in your config?

Collapse
 
wesleyjanse profile image
Wesley Janse

Yes I have that included, I have just added React-Dom as a peer dep, as a workaround. It is accessing the config file correctly though, just always wants to go back to ReactDom, but the workaround works, and since we need it anyway for storybook it's fine.

Thanks again for the blog!

Collapse
 
darkmattermatters profile image
SuperSegfault • Edited

I also have the same issue, only fixed by installing react-dom. It's probably worth mentionning that I did not include the Storybook part in my library and I did not publish on npm. But apart from that it's the same config files.
Also, moving react to peerDependencies does not work with Jest as he seems to need them in order to run the tests (because of the import in Button.test.tsx). Without Jest the packaging seems to work though.

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