RN 常见问题

时间:2023-03-08 16:17:50

React/RCTBridgeModule.h not found

#import <React/RCTBridgeModule.h> 全部替换为
#import "RCTBridgeModule.h"

同样也有可能遇到 #import "RCTBridgeModule.h" 找不到,可以尝试替换为 #import <React/RCTBridgeModule.h>

Ignoring return value of function declared with 'warn_unused_result' attribute

上述错误出现在 RCTWebSockect文件中

SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes);  全部替换为
(void)SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes);

另外一种解决方案(没试过)

int result = SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes);
assert(result == 0);

"react-native-scrollable-tab-view" 组件的ScrollableTabBar 默认选中效果出不来,也就是 initialPage 无效

react-native-scrollable-tab-view 使用的是 0.6.7 版本,到 ScrollableTabBar.js 中

this.props.scrollValue._value 全部替换为
this.props.scrollValue.__getValue()

或者到官网中 ()[https://github.com/skv-headless/react-native-scrollable-tab-view] 查看最新版本, 使用最新版本,

cd 工程目录
npm install react-native-scrollable-tab-view@0.7.4 --save
或者
yarn add react-native-scrollable-tab-view@0.7.4

FlatList 中 itemSeparate 部分分割线不显示

单元格item 使用的 TouchableOpacity 作为容器,当选中单元格,再上下滚动 list, 会发现itemSeparate 不显示

解决办法: TouchableOpacity 组件替换为 TouchableHighlight

npm install 报错 Unexpected end of JSON input while parsing near '...":"^1.21.4","should":'

 npm cache clean --force

xcrun: error: unable to find utility "instruments", not a developer tool or in PATH

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/

ERROR watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2018-03-13T10:13:24,997: [0x7fffa5a2d3c0] the permissions on /usr/local/var/run/watchman/ex-shili001-state allow others to write to it. Verify that you own the contents and then fix its permissions by running chmod 0700 /usr/local/var/run/watchman/ex-shili001-state

chmod 0700 /usr/local/var/run/watchman/ex-shili001-state

iOS react-native-splash-screen 卡在启动页

react-navigation 设置的 initialRouteName 不是启动页,调用不了 hide方法了

友情提醒:react-native-splash-screen 流程调通后,先把 native 中的 show 注释掉,以免快速调试的过程中设置的 initialRouteName 不是启动页,造成不必要的bug