react-decorator
v0.0.3
Published
an assortment of @decorators for react and react-native
Downloads
30
Maintainers
Readme
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...