How to run React-Native Examples?

后端 未结 9 2152
暗喜
暗喜 2021-01-31 21:18

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:

相关标签:
9条回答
  • 2021-01-31 21:49

    Here is a step by step tutorial for creating a simple application.

    1) First download the cli tool

    2) npm run start

    3) start the app in the xcode IOS simulator.

    Tutorial here: http://www.syntaxsuccess.com/viewarticle/553844b55bbbb6000031f0f9

    0 讨论(0)
  • 2021-01-31 21:53

    On Windows 10 I had to do adb shell am start -n com.facebook.react.movies/.MoviesActivity to get the examples running. (make sure ANDROID_SDK\platform-tools is in path or run command with absolute path)

    So step by step I had to do:

    cd react-native
    
    ./gradlew :Examples:Movies:android:app:installDebug
    
    adb shell am start -n com.facebook.react.movies/.MoviesActivity
    
    ./packager/packager.sh
    

    or

    ./gradlew :Examples:UIExplorer:android:app:installDebug
    
    adb shell am start -n com.facebook.react.uiapp/.UIExplorerActivity
    
    ./packager/packager.sh
    
    0 讨论(0)
  • 2021-01-31 21:54

    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];
    

    0 讨论(0)
  • 2021-01-31 21:56

    Also, you can run the android version of the UIExplorer app by running the command:

    ./gradlew :Examples:UIExplorer:android:app:installDebug
    ./packager/packager.sh
    

    or this:

    ./gradlew :Examples:Movies:android:app:installDebug
    ./packager/packager.sh
    

    for the movies example (should be run on the react-native folder).

    Also, you could run the gradle daemon to speed up the build time for Android.

    0 讨论(0)
  • 2021-01-31 22:00

    First, meet the requirements on the getting started guide

    Then, check out the React Native repository and run the following inside it:

    1. npm install
    2. open Examples/Movies/Movies.xcodeproj

    If you have errors compiling due to linking errors, removing the derived data may help. Quit Xcode, delete /Users/{you}/Library/Developer/Xcode/DerivedData, and re-open Xcode.

    0 讨论(0)
  • 2021-01-31 22:03
    1. brew update
    2. brew install node
    3. brew upgrade node (if u already installed)
    4. brew install watchman
    5. npm install -g react-native-cli
    6. react-native init [name ur app] --version 0.24.0(depends on which version u want to use, if it didn't work use below) (6). react-native init [name ur app] --verbose
    7. cd [name ur app]
    8. open .
    9. npm start
    10. atom . (if u installed atom)
    0 讨论(0)
提交回复
热议问题