Merge pull request #940 from sahrens/nativeComponentDocs
Update custom iOS component section of README to use requireNativeComponent
This commit is contained in:
commit
9458299683
20
README.md
20
README.md
|
@ -165,7 +165,7 @@ var Message = React.createClass({
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
Custom iOS views can be exposed by subclassing `RCTViewManager`, implementing a `-view` method, and exporting properties with the `RCT_EXPORT_VIEW_PROPERTY` macro. Then a simple JavaScript file connects the dots.
|
Custom iOS views can be exposed by subclassing `RCTViewManager`, implementing a `-view` method, and exporting properties with the `RCT_EXPORT_VIEW_PROPERTY` macro. Then use `requireNativeComponent` in JavaScript to use the component in your app.
|
||||||
|
|
||||||
```objc
|
```objc
|
||||||
// Objective-C
|
// Objective-C
|
||||||
|
@ -190,10 +190,20 @@ RCT_EXPORT_VIEW_PROPERTY(myCustomProperty, NSString);
|
||||||
```javascript
|
```javascript
|
||||||
// JavaScript
|
// JavaScript
|
||||||
|
|
||||||
var MyCustomView = createReactIOSNativeComponentClass({
|
var React = require('react-native');
|
||||||
validAttributes: { myCustomProperty: true },
|
var { requireNativeComponent } = React;
|
||||||
uiViewClassName: 'MyCustomView',
|
|
||||||
});
|
class MyCustomView extends React.Component {
|
||||||
|
render() {
|
||||||
|
return <NativeMyCustomView {...this.props} />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MyCustomView.propTypes = {
|
||||||
|
myCustomProperty: React.PropTypes.oneOf(['a', 'b']),
|
||||||
|
};
|
||||||
|
|
||||||
|
var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView);
|
||||||
|
module.exports = MyCustomView;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running the Examples
|
## Running the Examples
|
||||||
|
|
Loading…
Reference in New Issue