@simplus/robin-react
v1.0.8
Published
This is a react docorator for Robin
Downloads
83
Readme
README
This is a react docorator for Robin
Install
To use the package install it with npm
npm install --save @simplus/robin-reactUsage
In jour main file
You need to have created your RobinProvider and give it to the RobinReact main class in order to make the binding between react and the robin library
//robins.jsx
import RobinReact from '@simplus/robin-react'
import {RobinProvider, CollectionRobin} from '@simplus/robin'
const robins = {
aCollection : new CollectionRobin({ baseUrl : "/api/myCollection", })
}
const provider = new RobinProvider(robins)
RobinReact.setProvider(provider)
export {provider, robins}Then you can use the decorator to bind robins to a component
//component.jsx
import * as React from 'react'
import {connectRobin} from '@simplus/robin-react'
import {provider, robins} from './robins.jsx'
@connectRobin([robins.aCollection])
class MyComponent extends React.Component{
componentWillMount(){
robins.aCollection.find({})
}
render(){
return <div>
{this.props.aCollection.collection.map(item => {
return <div>{JSON.stringify(item)}</div>
})}
</div>
}
}
export { MyComponent }
export default MyComponentSee robin for more info
