Skip to content

Latest commit

 

History

History
51 lines (41 loc) · 1.05 KB

README.md

File metadata and controls

51 lines (41 loc) · 1.05 KB

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...