Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tonytonyjan/react-decorate-props

react-decorate is a higher-order component which can help you concat className, merge style and forward the rest of props.
https://github.com/tonytonyjan/react-decorate-props

react reactjs

Last synced: about 2 months ago
JSON representation

react-decorate is a higher-order component which can help you concat className, merge style and forward the rest of props.

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/tonytonyjan/react-decorate-props.svg?branch=master)](https://travis-ci.org/tonytonyjan/react-decorate-props)

# react-decorate-props

react-decorate-props is a [higher-order component](https://reactjs.org/docs/higher-order-components.html) which can help you concat `className`, merge `style` and forward the rest of props. No more`const {className, style, ...others} = this.props` in `render()`.

# Usage

```jsx
// Instead of...
class Foo extends React.Component {
render() {
const { className, style, ...others } = this.props;
const rootClass = "root";
const rootStyle = { color: "red", backgroundColor: "green" };
return (


);
}
}

// ...wrap component with HOC...
import decorate from "react-decorate-props";
class Foo extends React.Component {
render() {
const rootClass = "root";
const rootStyle = { color: "red", backgroundColor: "green" };
return

;
}
}
export default decorate(Foo);

// ...and in the consuming module...
;

// ... HTML output:
//

```