How to run React-Native Examples?

后端 未结 9 2153
暗喜
暗喜 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 22:09

    1) Open your terminal and cd to the specific example you want to run cd home/XYZ/react-native-master/Examples/UIExplorer

    2) run npm install

    3) run npm start

    4) Open the example in Xcode and run it from there It should work fine.

    PS: It was so simple but a lot of answers mislead me too.

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

    You have to install node.js in your Terminal with

    brew install node
    

    ReactNative use Node.js to build the Javascript code inside the project.

    Then you need Watchman, a file watcher from Facebook with

    brew install watchman
    

    React Native use Watchman to rebuild your code when there's a change in it.

    The final thing is to install and run node with a Terminal window in the react-native folder.

    npm install
    npm start
    

    Now you can open a project from the react-native/Examples folder in Xcode, then build and run it.

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

    Just wanted to update this for people just trying to run an existing react-native project/app like me:

    In Terminal:

    1. npm install
    2. npm start (should open a separate window to run react package manager or it may use the existing terminal window, if that is the case you will need to open a new terminal window to type the command for step 3)
    3. react-native run-ios/react-native run-android

    **you may want to run npm update -g (while in the react native folder) to ensure all the npm packages are up to date before running npm install

    0 讨论(0)
提交回复
热议问题