RN常见问题备忘:

2020-07-06  本文已影响0人  dfqin
  1. 设置了borderRadius后再设置borderWidth无效

  2. 0.62.2版本开发,在Android手机上debug,无法命中onPress事件。
    https://github.com/facebook/react-native/issues/27008

  3. useReducer,reducer多调用一次,把reducer函数写到外面就好了
    https://stackoverflow.com/questions/54892403/usereducer-action-dispatched-twice
    https://stackoverflow.com/questions/54715188/react-hook-rendering-an-extra-time/54716601#54716601

  4. 在ScrollView中存在TextInput,ScrollView中的按钮无法响应点击。后面发现是ScrollView的此属性导致的--keyboardShouldPersistTaps,当键盘显示时,点击事件默认被ScrollView接收用来收起键盘

  5. 页面中有些view是吸低的,但是显示键盘时会把吸低的view推上去,这时在androidmanifest中设置ReactActivity android:windowSoftInputMode="adjustPan"可以解决,但是在Modal中这个设置无效,可以
    用<KeyboardAvoidingView enabled={false} >包裹内容解决这个问题,有关讨论 https://github.com/react-native-community/react-native-modal/issues/344

  6. 打release包时报错:

 Task :app:bundleReleaseJsAndAssets
warning: the transform cache was reset.
error The resource `/Users/user/GitZA/zaloan-app/index.js` was not found. Run CLI with --verbose flag for more details.
Error: The resource `/Users/user/GitZA/zaloan-app/index.js` was not found.
    at /Users/user/GitZA/zaloan-app/node_modules/metro/src/IncrementalBundler.js:157:26
    at gotStat (fs.js:1787:21)
    at FSReqCallback.oncomplete (fs.js:175:21)

因为是混合项目,原生项目里面只是集成RN框架,没有js项目代码,按说不该去找index.js这类文件,感觉是RN库的脚本什么地方出错了,目前可以通过下面命令跳过这一步正常打包(参考:这里)

./gradlew assembleRelease -x bundleReleaseJsAndAssets

经排查是因为build.gradle执行了下面脚本,移除即可:

/node_modules/react-native/react.gradle"
  1. 多个Modal同时显示
    项目中会有场景,一个弹框上操作,会触发显示另外一个弹窗,在android中是可以正常显示的,但是在iOS上发现第一个弹窗显示时,无法触发显示其他弹窗,查了一些资料,目前大家都是使用Modal嵌套的方式来实现
    https://github.com/facebook/react-native/issues/3445
    https://github.com/react-native-community/react-native-modal/issues/30

  2. RN中列表性能问题
    使用RecycleListView https://blog.csdn.net/sinat_17775997/article/details/104455046

上一篇 下一篇

猜你喜欢

热点阅读