React常见报错

前端之家收集整理的这篇文章主要介绍了React常见报错前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


一。Failed run android simulator : No connected devices!

https://github.com/facebook/react-native/issues/3091


When you have the platform,and the device,you can then boot the device with emulator:

$ emulator -avd <name>@H_403_23@ 

Once booted,the command you were likely trying to runreact-native run-androidshould produce the effect of a react mobile app running in your emulator window.




二。ReactNative经典报错



解决办法:


1.


注意 Android5.0以上版本命令方式:
打开AndroidSDK目录xxx\Android\sdk\platform-tools。在当前文件路径呼出命令行,输入:
adbreversetcp:8081tcp:8081@H_403_23@
点击ReloadJS即可成功拉取ReactNativebundle。@H_403_23@

2.
我们摇一摇手机,点击 DevSettings后,点击 Debugserverhost&portfordevice,设置IP和端口。

这里的IP是电脑的IP,端口号固定8081。
设置完成后,回到空白页面,再次摇一摇手机,选择ReloadJS,程序就运行起来,出现WelcometoReactNative!

这个信息是在项目目录下 index.android.js里的,可以打开看看:
class HelloAndroid extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started,edit index.android.js
        </Text>
        <Text style={styles.instructions}>
          Shake or press menu button for dev menu
        </Text>
      </View>
    );
  }
}
原文链接:https://www.f2er.com/react/306456.html

猜你在找的React相关文章