get started with React Native-001
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了get started with React Native-001,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2332字,纯文字阅读大概需要4分钟。
内容图文
http://facebook.github.io/react-native/docs/getting-started.html#content
Requirements
- OS X - This repo only contains the iOS implementation right now, and Xcode only runs on Mac.
- New to Xcode? Download it from the Mac App Store.
- Homebrew is the recommended way to install node, watchman, and flow.
-
brew install node
. New to node or npm? -
brew install watchman
. We recommend installing watchman, otherwise you might hit a node file watching bug. -
brew install flow
. If you want to use flow.
Quick start
-
npm install -g react-native-cli
-
react-native init AwesomeProject
In the newly created folder AwesomeProject/
- Open
AwesomeProject.xcodeproj
and hit run in Xcode - Open
index.ios.js
in your text editor of choice and edit some lines - Hit cmd+R (twice) in your iOS simulator to reload the app and see your change!
Congratulations! You‘ve just successfully run and modified your first React Native app.
创建项目初次打开的项目结构
#import "AppDelegate.h" #import "RCTRootView.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSURL *jsCodeLocation; // Loading JavaScript code - uncomment the one you want. // OPTION 1 // Load from development server. Start the server from the repository root: // // $ npm start // // To run on device, change `localhost` to the IP address of your computer, and make sure your computer and // iOS device are on the same Wi-Fi network. jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"]; // OPTION 2 // Load from pre-bundled file on disk. To re-generate the static bundle, run // // $ curl http://localhost:8081/index.ios.bundle -o main.jsbundle // // and uncomment the next following line // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"AwesomeProject" launchOptions:launchOptions]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [[UIViewController alloc] init]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return YES; }
原文:http://blog.csdn.net/yuhu718780261/article/details/44672501
内容总结
以上是互联网集市为您收集整理的get started with React Native-001全部内容,希望文章能够帮你解决get started with React Native-001所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。