如何运行React-Native示例? [英] How to run React-Native Examples?
问题描述
我找不到有关如何安装和运行中提供的其他示例之一的任何说明https://github.com/facebook/react-native/tree/master/Examples ',例如' https://github.com/facebook/react-native/tree/master/Examples/Movies '。
仅限教程告诉你这样做
react-native init AwesomeProject
<抓住' https://github.com/facebook/react-native/tree/master / Examples / SampleApp '。
如果我克隆整个'react-native'存储库,然后运行
npm install
npm start
从根文件夹(即'/ react-native'),然后打开'/ react-native / Examples / Mo在Xcode中的vies / Movies.xcodeproj'和运行项目,似乎构建正常。模拟器出现,显示应用程序的电影介绍屏幕,但随后出现红色死亡屏幕,打印出来:
:0
和终端,其中'npm start'在根文件夹中运行,打印出来:
错误:EISDIR,错误(原生)
读取
[02:35: 02]< START>要求:/Examples/Movies/MoviesApp.includeRequire.runModule.bundle
只需遵循使用入门教程即可。你必须在react-native目录中运行 npm install
。
然后运行例如电影项目Xcode。
如果你想隔离MovieProject或其他反应原生的示例项目,那么简单的方法是初始化一个新的反应原生应用程序( react-native init MyAppName
)并将示例项目中的JS文件(在Movie Project中的示例中)复制到新的app文件夹中。
然后不要忘记编辑你的iOS / AppDelegate.m文件。
你必须编辑2行:
jsCodeLocation = [NSURL URLWithString:@http:/ localhost:8081 / index.ios.bundle];
按:
jsCodeLocation = [NSURL URLWithString:@http:// localhost:8081 / MoviesApp.bundle];
AND
RCTRootView * rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@MyAppName
launchOptions:launchOptions];
按:
RCTRootView * rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@MoviesApp
launchOptions:launchOptions];
I can't find any instructions on how to install and run one of the other Examples provided in 'https://github.com/facebook/react-native/tree/master/Examples' such as 'https://github.com/facebook/react-native/tree/master/Examples/Movies'.
The tutorial only tells you to do
react-native init AwesomeProject
which grabs 'https://github.com/facebook/react-native/tree/master/Examples/SampleApp'.
If I clone the entire 'react-native' repository, and then run
npm install
npm start
From the root folder (i.e. '/react-native'), and then open '/react-native/Examples/Movies/Movies.xcodeproj' in Xcode, and Run the project, it seems to build fine. The Simulator comes up, shows a "Movies" intro screen for the app, but then the red screen of death appears with a print out of:
:0
and Terminal, where 'npm start' is running at the root folder, prints out:
Error: EISDIR, read
at Error (native)
[02:35:02] <START> request:/Examples/Movies/MoviesApp.includeRequire.runModule.bundle
It should work just by following the Getting Started Tutorial, except that you have to run npm install
inside your react-native directory.
Then just run for example the Movie Project with Xcode.
If you want to "isolate" the MovieProject or another react-native example project, the easy way is to init a new react native app (react-native init MyAppName
) and just copy the JS files from the example project (in the example below the Movie Project) into the new app folder.
And then don't forget to edit your iOS/AppDelegate.m file.
You have to edit 2 lines:
jsCodeLocation = [NSURL URLWithString:@"http:/localhost:8081/index.ios.bundle"];
By:
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/MoviesApp.bundle"];
AND
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"MyAppName"
launchOptions:launchOptions];
By:
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"MoviesApp"
launchOptions:launchOptions];
这篇关于如何运行React-Native示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!