kriasoft / isomorphic-style-loader

CSS style loader for Webpack that is optimized for isomorphic (universal) web apps.

Home Page:https://reactstarter.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[question] is this loader suitable for wrapping a small single component intended to be used by multiple apps, some with and some without SSR?

RwwL opened this issue · comments

I'm not sure if I'm understanding the docs correctly, but it seems like if I just have a single component I want to distribute to be used by multiple apps produced by my organization, the best choice is to use the withStyles HOC and wrap my component, since wrapping a styleContext seems more like it's meant to be a top-of-the-tree, whole-app approach. These apps are maintained by different teams, some aren't even full React apps and will just use some React components along side other custom JS app frameworks, and it seems wrong to have make any significant changes to them to consume a single component.

But if I do this, create a production build, and publish it to our GitHub package registry, can other apps consume this component and expect to get its styles handled properly, server or client, with no other changes on their end? It seems like maybe not, as I'm seeing the TypeError: Cannot read property 'apply' of null issue in my first attempt to use my exported component in a consuming app (one that's not using SSR, was generated with create-react-app, and I haven't touched its Webpack configuration yet because I'm unsure if that should be necessary).

Related question: in the repo where we develop this shared single component, we have a reference app that was also generated with create-react-app to use during development — am I correct in assuming that I really have no option but to eject from CRA to be able to change webpack development setup to use ismorphic-style-loader?