jbetancur / react-data-table-component

A responsive table library with built-in sorting, pagination, selection, expandable rows, and customizable styling.
https://react-data-table-component.netlify.app
Apache License 2.0
2.05k stars 413 forks source link

This dependency was not found: npm install --save styled-components #216

Closed Steffi3rd closed 5 years ago

Steffi3rd commented 5 years ago

Describe the bug

This dependency was not found:

To install it, you can run: npm install --save styled-components

I don't want to use Styled Components, I already use Emotion.

Can we avoid to install it?

To Reproduce

yarn add react-data-table-component

jbetancur commented 5 years ago

RDT's styling is built atop styled components and it's required as a peer dependency. It would not be possible without re-writing half the library. I initially thought about writing RDT with scss to keep things un-opinionated but it added a ton of overhead.

btw, if space is a concern, styled-components v5 is 12.33kB min+gzip at 4.3.x is around 16kb.

jbetancur commented 5 years ago

It would be interesting though if we could abstract the css-in jss to where you could bring your own 🤔

m4rcelofs commented 5 years ago

I'm curious as to why styled-components is a peer dependency instead of a dependency of react-data-table-component, though. Makes our package.json a little polluted.

@jbetancur any thoughts on that?

jbetancur commented 5 years ago

@m4rcelofs I had the same concerns about package.json "pollution" and install confusion, but my rationale for this was for cases where you use a styled-components version that is different than RDT's version. In that case, if you use styled-components in your app, then having it as a dep increases the bundle size unnecessarily so. I believe you would then have multiple version of styled-components instead of just one dependency and I am not even sure what sort of bugs that would introduce.

Aside from that, what put me over the edge was that styled-components recommends against bundling it in with libraries:

https://www.styled-components.com/docs/faqs#i-am-a-library-author-should-i-bundle-styledcomponents-with-my-library

Hope that clarifies.