Pit encountered in React-Native learning


How to install react-native on Mac can be found. Here are some small problems encountered in the just learning:


1. The problem as shown in the figure below is installed according to the steps on the react-native Chinese website , and the following problem occurs when running:

Here you need to modify a piece of code in Appdelegate:

  jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

replace with

  jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8081/index.ios.bundle?platform=ios&dev=true"];
















2. After the above modification, the following problems will occur:

 The file of index.ios.js cannot be found   in the file, here I  modified the index.js in the project to index.ios.js 




Follow the above two steps to run normally. This is just a problem running on my computer. If the above problem occurs in the future, I will continue to modify it.

3. The above is the problem of running in the simulator. Here is what needs to be modified to run on a real machine

In Appdelegate, you need to change the IP address to the address of your own computer. It is especially important to note that the wifi connected to the mobile phone and the wifi of the computer are the same

If you have a better solution, please leave a message, thank you!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325770765&siteId=291194637