Skip to content

Commit 101e019

Browse files
author
Robin Frischmann
committed
update docs
1 parent 878afe0 commit 101e019

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

README.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# CSS via Components
22

33
A single React component to inject CSS with ease.<br>
4-
It works with SSR (even using React 16's [renderToNodeStream](https://reactjs.org/docs/react-dom-server.html#rendertonodestream)) and client-side rendering out-of-the-box.
4+
It works with SSR (even using React 16's [renderToNodeStream](https://reactjs.org/docs/react-dom-server.html#rendertonodestream)) and client-side rendering out-of-the-box.<br>
5+
It also provides an *optional* optimisation path.
56

67
<img alt="TravisCI" src="https://travis-ci.org/rofrischmann/react-css-component.svg?branch=master"> <a href="https://codeclimate.com/github/rofrischmann/react-css-component/coverage"><img alt="Test Coverage" src="https://codeclimate.com/github/rofrischmann/react-css-component/badges/coverage.svg"></a> <img alt="npm version" src="https://badge.fury.io/js/react-css-component.svg"> <img alt="npm downloads" src="https://img.shields.io/npm/dm/react-css-component.svg"> <img alt="dependencies" src="https://david-dm.org/rofrischmann/react-css-component.svg">
78

@@ -34,17 +35,21 @@ Depending on whether [universal rendering](#universalrendering) (server-side ren
3435
#### Caveat
3536
During server-side rendering, the [UniversalStyle](#style) component is not able to track it's own occurence, which may result in duplicate *style* elements. **This won't break anything, but also is not optimal**. To ensure that each [UniversalStyle](#style) instance is only rendered once, we need an unique cache on every render. This is achieved by passing a simple cache via React's context feature. Check the [StyleCacheProvider](#stylecacheprovider) component for more information.
3637

37-
38-
3938
### Client-Only Rendering
4039
If we only render on the client-side anyways, we can skip that complex flow and just use the [ClientStyle](#style).<br>
4140
It simply injects a *style* element into the `document.head` on instantiation and tracks its occurence using a global cache.
4241

4342
> **Note**: The [ClientStyle](#style) component won't throw with server-side rendering, but it simply doesn't render styles.
4443
44+
## When?
45+
It is important to point out, that this component does not fit for every use case.<br>
46+
It is especially built to be used for resuable shared components: If you're building a small React component and want to share it on npm, this is the perfect solution to add styling without having any additional setup on the user-side.<br>
47+
But, it should be used with caution when building applications. It does **not** solve common CSS problems such as specificity issues, global namespace conflicts or autoprefixing. Consider using a [CSS in JS library](http://michelebertoli.github.io/css-in-js/), [CSS Modules](https://github.com/css-modules/css-modules) or whatever tool is actually built with full applications in mind.
48+
49+
4550
## Style
46-
Both `UniversalStyle` and `ClientStyle` share the exact same component API.<br>
47-
This component is the core component and is used to inject the CSS.
51+
This component is the core component and is used to inject the CSS.<br>
52+
Both the universal and the client-only version share the exact same API.
4853

4954
### Props
5055

0 commit comments

Comments
 (0)