react-decorator

v0.0.3
an assortment of @decorators for react and react-native
decorators react react-native annotation higher-order-components hoc es7

React Decorators

An assortment of useful @decorators for react and react-native

Warning! - If you're using babel 6, you'll have to use babel-plugin-transform-decorators-legacy plugin [Follow thread]. If you're using babel 5, you're good to go.

installation

npm i -S react-decorator

Usage

Request

import React, { Component } from 'react'
import { request } from 'react-decorator'

@request({
    task: fetch(url),
    LoadingComponent: () => <div>loading....</div>,
    ErrorComponent: ({ error }) => <div>{ error }</div>,
})
class App extends Component {
    render() {
        return <div> content </div>
    }
}

Measure

import React, { Component } from 'react'
import { measure } from 'react-decorator'

@measure
class App extends Component {
    render () {
        return (
            <div>
                This text fits inside a
                { this.props.width }x{ this.props.height }
                box
            </div>
        )
    }
}

More coming soon...

npm i react-decorator

Metadata

  • MIT
  • Whatever
  • Pawan Kumar
  • released 4/16/2017

Downloads

Maintainers