Added the parsing of bindings from the propTypes when present

This commit is contained in:
Matias Ribichich
2017-03-15 21:58:01 -03:00
parent ecd046d40e
commit d59b511d74
3 changed files with 95 additions and 6 deletions
+43
View File
@@ -46,6 +46,49 @@ angular
></my-component>
```
## Usage 2 (Alternative)
As an alternative you can specify the propTypes in your component, and it'll be use automatically as the bindings
### 1. Create a React component
```js
import { Component } from 'react'
class MyComponent extends Component {
static propTypes = {
fooBar: React.PropTypes.number.isRequired,
baz: React.PropTypes.string.isRequired
}
render() {
return <div>
<p>FooBar: {this.props.fooBar}</p>
<p>Baz: {this.props.baz}</p>
</div>
}
}
```
### 2. Expose it to Angular
```js
import { react2angular } from 'react2angular'
angular
.module('myModule', [])
.component('myComponent', react2angular(MyComponent))
```
### 3. Use it in your Angular 1 code
```html
<my-component
foo-bar="3"
baz="'baz'"
></my-component>
```
## Tests
```sh