A declarative, nested way to manipulate your body's className
npm install react-body-classname[![NPM version][npm-image]][npm-url]
[![Downloads][downloads-image]][npm-url]
[![Dependency status][david-dm-image]][david-dm-url]
Provides a declarative way to specify document.body.className in your react app. Supports server-side usage too.
Built with React Side Effect.
---
```
yarn add react-body-classname
Dependencies: React >= 0.13.0
`jsx
import BodyClassName from 'react-body-classname';
const Basic = () => (
You ate a whole wheel of cheese?
);
// -> document.body.className === "helloworld"
const Nested = () => ( I‘m not even mad
);
// -> document.body.className === "outside inside"
const GoCrazy = () => (
I'm impressed
);
// -> document.body.className === "NaNNaNNaNNaNNaNNaNNaN batman!"
`
Note: Only supports a single child as props.
When using server-side, use BodyClassName.rewind() _after rendering components to string_ to retrieve the combined class name. Then chuck that into your HTML template.
Important: This component keeps track of mounted instances, so if you don't call BodyClassName.rewind()` you'll get a memory leak.
[npm-url]: https://npmjs.org/package/react-body-classname
[downloads-image]: http://img.shields.io/npm/dm/react-body-classname.svg
[npm-image]: http://img.shields.io/npm/v/react-body-classname.svg
[david-dm-url]:https://david-dm.org/iest/react-body-classname
[david-dm-image]:https://david-dm.org/iest/react-body-classname.svg