iOS在原有项目中使用react
2016-07-07 10:15
573 查看
代码下载地址: https://github.com/leicunjie/OCWithReact
0.使用Xcode创建项目
1. 在Podfile中添加:
pod 'React', :path => './node_modules/react-native', :subspecs => [
'Core',
'RCTImage',
'RCTNetwork',
'RCTText',
'RCTWebSocket',
# Add any other subspecs you want to use in your project
]
2.pod install
3.在根目录创建index.ios.js文件
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
View,
Text,
} from 'react-native'
class OCWithReactDemo extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions}>
Shake or press menu button for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('OCWithReactDemo', () => OCWithReactDemo);
3.在根目录执行命令 nam install react-native
4.在buildSetting 的 User Header Search Path中添加:
$(PODS_ROOT)/React/React
选择 recursive
5.启动react服务器,运行工程。
0.使用Xcode创建项目
1. 在Podfile中添加:
pod 'React', :path => './node_modules/react-native', :subspecs => [
'Core',
'RCTImage',
'RCTNetwork',
'RCTText',
'RCTWebSocket',
# Add any other subspecs you want to use in your project
]
2.pod install
3.在根目录创建index.ios.js文件
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
View,
Text,
} from 'react-native'
class OCWithReactDemo extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions}>
Shake or press menu button for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('OCWithReactDemo', () => OCWithReactDemo);
3.在根目录执行命令 nam install react-native
4.在buildSetting 的 User Header Search Path中添加:
$(PODS_ROOT)/React/React
选择 recursive
5.启动react服务器,运行工程。
相关文章推荐
- redux学习记录
- genymotion Ubuntu 错误
- react调用原生iOS方法
- 浅析React之通信机制(一)
- 【转】什么是Reactor模式,或者叫反应器模式
- react-native scrollView 中部分有用事件
- React-Natvie run-android 出现错误
- 使用 Babel + React + Webpack 搭建 Web 应用
- [转] React Router 使用教程
- React Native
- ReactiveX-入门篇
- ReactiveCocoa系列之signal流程详解
- 史上最详细Windows版本搭建安装React Native环境配置
- React/React Native 的ES5 ES6写法对照表-b
- ReactiveCocoa 浅析
- # ReactiveCocoa - 进阶篇
- React Native的自我实践之window下的安装
- ReactOS 新手指南
- React Native学习笔记之一
- React Native学习-将 'screen', 'window' or a view生成图片