0.0.1 • Published 7 years ago

react-document-style v0.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

react-document-style

We could render style component either client or server side via react-side-effect.

build status Test coverage NPM version NPM Downloads

  • UMD unpak

Usage

The Component writing like here.

import Style from 'react-document-style'
const css = 'body { color: red; }'

export default () => (
  <Style css={css}>
    <div>
      Hi
      <Style css={'div { color: blue; }'}/>
    </div>
  </Style>
)
  • Client
    Would create a style DOM in head
<head>
<style type="text/css">
body { color: red; }
div { color: blue; }
</style>
</head>
  • Server
    Call rewind or peek to get the css string on server side after render component.
    please see the doc about react-side-effect for more information
ReactServerDOM.renderToString(<Style css={'div { color: blue; }'}/>)
Style.peek() // div { color: blue; }
Style.rewind() // div { color: blue; }
Style.peek() // undefined