Update README.md

This commit is contained in:
Spencer Ahrens 2015-03-26 10:52:14 -07:00
parent b687184c68
commit ecc0032c4e
1 changed files with 15 additions and 0 deletions

View File

@ -10,6 +10,7 @@ With React Native, you can use the standard platform components such as UITabBar
```javascript ```javascript
var React = require('react-native'); var React = require('react-native');
var { TabBarIOS, NavigatorIOS } = React; var { TabBarIOS, NavigatorIOS } = React;
var App = React.createClass({ var App = React.createClass({
render: function() { render: function() {
return ( return (
@ -37,6 +38,7 @@ iOS has a very powerful system called the Responder Chain to negotiate touches i
```javascript ```javascript
var React = require('react-native'); var React = require('react-native');
var { ScrollView, TouchableHighlight, Text } = React; var { ScrollView, TouchableHighlight, Text } = React;
var TouchDemo = React.createClass({ var TouchDemo = React.createClass({
render: function() { render: function() {
return ( return (
@ -57,6 +59,7 @@ Laying out views should be easy, which is why we brought the flexbox layout mode
```javascript ```javascript
var React = require('react-native'); var React = require('react-native');
var { Image, StyleSheet, Text, View } = React; var { Image, StyleSheet, Text, View } = React;
var ReactNative = React.createClass({ var ReactNative = React.createClass({
render: function() { render: function() {
return ( return (
@ -93,6 +96,7 @@ React Native is focused on changing the way view code is written. For the rest,
```javascript ```javascript
var React = require('react-native'); var React = require('react-native');
var { Text } = React; var { Text } = React;
var GeoInfo = React.createClass({ var GeoInfo = React.createClass({
getInitialState: function() { getInitialState: function() {
return { position: 'unknown' }; return { position: 'unknown' };
@ -119,9 +123,12 @@ It is certainly possible to create a great app using React Native without writin
```objc ```objc
// Objective-C // Objective-C
#import "RCTBridgeModule.h" #import "RCTBridgeModule.h"
@interface MyCustomModule : NSObject <RCTBridgeModule> @interface MyCustomModule : NSObject <RCTBridgeModule>
@end @end
@implementation MyCustomModule @implementation MyCustomModule
- (void)processString:(NSString *)input callback:(RCTResponseSenderBlock)callback - (void)processString:(NSString *)input callback:(RCTResponseSenderBlock)callback
{ {
@ -133,8 +140,10 @@ It is certainly possible to create a great app using React Native without writin
```javascript ```javascript
// JavaScript // JavaScript
var React = require('react-native'); var React = require('react-native');
var { NativeModules, Text } = React; var { NativeModules, Text } = React;
var Message = React.createClass({ var Message = React.createClass({
render: function() { render: function() {
getInitialState() { getInitialState() {
@ -156,20 +165,26 @@ Custom iOS views can be exposed by subclassing `RCTViewManager`, implementing a
```objc ```objc
// Objective-C // Objective-C
#import "RCTViewManager.h" #import "RCTViewManager.h"
@interface MyCustomViewManager : RCTViewManager @interface MyCustomViewManager : RCTViewManager
@end @end
@implementation MyCustomViewManager @implementation MyCustomViewManager
- (UIView *)view - (UIView *)view
{ {
return [[MyCustomView alloc] init]; return [[MyCustomView alloc] init];
} }
RCT_EXPORT_VIEW_PROPERTY(myCustomProperty); RCT_EXPORT_VIEW_PROPERTY(myCustomProperty);
@end`} @end`}
``` ```
```javascript ```javascript
// JavaScript // JavaScript
module.exports = createReactIOSNativeComponentClass({ module.exports = createReactIOSNativeComponentClass({
validAttributes: { myCustomProperty: true }, validAttributes: { myCustomProperty: true },
uiViewClassName: 'MyCustomView', uiViewClassName: 'MyCustomView',