Skip to content

Commit 1fa55c2

Browse files
committed
Update custom iOS component section to use requireNativeComponent
1 parent 3e8b41f commit 1fa55c2

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ var Message = React.createClass({
165165
});
166166
```
167167

168-
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.
168+
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.
169169

170170
```objc
171171
// Objective-C
@@ -190,10 +190,20 @@ RCT_EXPORT_VIEW_PROPERTY(myCustomProperty, NSString);
190190
```javascript
191191
// JavaScript
192192
193-
var MyCustomView = createReactIOSNativeComponentClass({
194-
validAttributes: { myCustomProperty: true },
195-
uiViewClassName: 'MyCustomView',
196-
});
193+
var React = require('react-native');
194+
var { requireNativeComponent } = React;
195+
196+
class MyCustomView extends React.Component {
197+
render() {
198+
return <NativeMyCustomView {...this.props} />;
199+
}
200+
}
201+
MyCustomView.propTypes = {
202+
myCustomProperty: React.PropTypes.oneOf(['a', 'b']),
203+
};
204+
205+
var NativeMyCustomView = requireNativeComponent('MyCustomView', MyCustomView);
206+
module.exports = MyCustomView;
197207
```
198208

199209
## Running the Examples

0 commit comments

Comments
 (0)