文章目录
ReactNative常见的报错,踩坑
持续更新中。。。。
常见错误
点击事件,点击了几次就发生这样的错误
Attempted to transition from state RESPONDER_INACTIVE_PRESS_IN to RESPONDER_ACTIVE_LONG_PRESS_IN, which is not supported. This is most likely due to Touchable.longPressDelayTimeout not being cancelled.
解决方法: 用TouchableOpacity
把元素包起来,并且把事件注册到这个元素中
使用字体图标时,执行程序发现了这样的报错
> Task :react-native-vector-icons:generateDebugBuildConfig FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
68 actionable tasks: 30 executed, 38 up-to-date
ע: E:\Exercise\reactNative\todos\node_modules\react-native-gesture-handler\android\src\main\java\com\swmansion\gesturehandler\react\RNGestureHandlerButtonViewManager.javaʹ�û����ѹ�ʱ�� API�
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
ע: ijЩ�����ļ�ʹ����δ������ȫ�IJ�����
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:unchecked ���±��롣
ע: E:\Exercise\reactNative\todos\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesManager.javaʹ�û����ѹ�ʱ�� API��
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
ע: E:\Exercise\reactNative\todos\node_modules\react-native-reanimated\android\src\main\java\com\swmansion\reanimated\NodesManager.javaʹ����δ������ȫ�IJ�����
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:unchecked ���±��롣
ע: ijЩ�����ļ�ʹ�û����ѹ�ʱ�� API��
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
ע: ijЩ�����ļ�ʹ����δ������ȫ�IJ�����
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:unchecked ���±��롣
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-vector-icons:generateDebugBuildConfig'.
> java.io.IOException: Unable to delete directory E:\Exercise\reactNative\todos\node_modules\react-native-vector-icons\android\build\generated\source\buildConfig\debug\com\oblador.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 11s
解决方法:重新按照官网配置一下react-native-vector-icons
即可
使用FlatList添加justifyContent出现这样的报错
Invariant Violation: ScrollView child layout (["justifyContent"]) must be applied through the contentContainerStyle prop.
解决方法:把样式写在/指定在contentContainerStyle
程序不刷新
执行的程序会弹出一个nodeJS窗口可以让当控制台来使用,或者来刷新程序,但是按R时程序只显示Reloading app...
没有按个绿条重新加载
解决方法:打开debug网页,打开控制台,在浏览器刷新按钮那右键,选择清空缓存和硬性重新加载
常见警告
Debug页面没在焦点状态
Remote debugger is in a background tab which may cause apps to perform slowly. Fix this by foregrounding the tab (or opening it in a separate window).
解决方法:这是你开启了Debug功能后,如果当前网页不是这个debug页面则会报这个警告