总结React Native开发中遇到的错误 仅供提醒自己

总结React Native开发中遇到的错误 仅供提醒自己

React Native 遇到问题总结

1、/Users/andrariztyan/MyProject/mobile/myapp/App.js: The module ./../react-transform-hmr/lib/index.js could not be found from /Users/andrariztyan/MyProject/mobile/myapp/App.js. Indeed, none of these files exist:

* /Users/andrariztyan/MyProject/mobile/react-transform-hmr/lib/index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)

* /Users/andrariztyan/MyProject/mobile/react-transform-hmr/lib/index.js/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx) 最开始是将创建的文件都放在文件夹里报这个错 后来将这些文件全部放在外面和index.js同级还是报这个错误 同样的环境下创建一个新工程还是报这个错误 我都服了 各种百度都没找到 最后在GitHub上搜索出的答案

使用的方法  react-native start --reset-cache   清理一下缓存   然后关闭模拟器 重新运行就好了 还是要多多使用这个网站

2、console .error :"React Native version mismatch

JavaScript version:0.59.2

Native version:0.58.6

这个问题简单点说就是运行了两个node版本不同的rn项目就产生了报错 产生的原因则是每次创建新的rn项目的时候都会默认按最新的node版本创建 当同时运行多个项目的时候就会出现版本不匹配的问题 我的解决办法是退出xcode 模拟器以及rn编译器 然后再打开运行 问题解决   https://blog.csdn.net/SkySmile1992/article/details/86611111

3、 Invariant Violation: Invariant Violation: Objects are not valid as a React child (found: object with keys {}). If you meant to render a collection of children, use an array instead.

in RCTView (at View.js:45)

in View (at createAnimatedComponent.js:153)

in AnimatedComponent (at CrossFadeIcon.js:34)

in RCTView (at View.js:45)

in View (at CrossFadeIcon.js:33)

in TabBarIcon (at BottomTabBar.js:151)

in RCTView (at View.js:45)

in View (at BottomTabBar.js:70)

in TouchableWithoutFeedback (at BottomTabBar.js:63)

in TouchableWithoutFeedbackWrapper (at BottomTabBar.js:237)

in RCTView (at View.js:45)

in View (at createAnimatedComponent.js:153)

in AnimatedComponent (at react-native-safe-area-view/index.js:153)

in SafeView (at withOrientation.js:54)

in withOrientation (at BottomTabBar.js:219)

in TabBarBottom (at withDimensions.js:32)

in withDimensions(TabBarBottom) (at createBottomTabNavigator.js:72)

in RCTView (at View.js:45)

in View (at createBottomTabNavigator.js:102)

in TabNavigationView (at createTabNavigator.js:197)

in NavigationView (created by Navigator)

in Navigator (at createAppContainer.js:388)

in NavigationContainer (at renderApplication.js:34)

in RCTView (at View.js:45)

in View (at AppContainer.js:98)

in RCTView (at View.js:45)

in View (at AppContainer.js:115)

in AppContainer (at renderApplication.js:33)

This error is located at:

in RCTView (at View.js:45)

in View (at createAnimatedComponent.js:153)

in AnimatedComponent (at CrossFadeIcon.js:34)

in RCTView (at View.js:45)

in View (at CrossFadeIcon.js:33)

in TabBarIcon (at BottomTabBar.js:151)

in RCTView (at View.js:45)

in View (at BottomTabBar.js:70)

in TouchableWithoutFeedback (at BottomTabBar.js:63)

in TouchableWithoutFeedbackWrapper (at BottomTabBar.js:237)

in RCTView (at View.js:45)

in View (at createAnimatedComponent.js:153)

in AnimatedComponent (at react-native-safe-area-view/index.js:153)

in SafeView (at withOrientation.js:54)

in withOrientation (at BottomTabBar.js:219)

in TabBarBottom (at withDimensions.js:32)

in withDimensions(TabBarBottom) (at createBottomTabNavigator.js:72)

in RCTView (at View.js:45)

in View (at createBottomTabNavigator.js:102)

in TabNavigationView (at createTabNavigator.js:197)

in NavigationView (created by Navigator)

in Navigator (at createAppContainer.js:388)

in NavigationContainer (at renderApplication.js:34)

in RCTView (at View.js:45)

in View (at AppContainer.js:98)

in RCTView (at View.js:45)

in View (at AppContainer.js:115)

in AppContainer (at renderApplication.js:33)

这个我想说我各种搜索没找到 是因为在创建createBottomTabNavigator时多了一句代码  如下

tabBarIcon:{

}

我猜测应该是不能为空

export const AppStackNavigator = createBottomTabNavigator({

homeNavigator1:{

screen:homeNavigator,

navigationOptions:{

tabBarLabel:'首页',

tabBarIcon:{

}

}

},

你可能感兴趣的:(总结React Native开发中遇到的错误 仅供提醒自己)