第一次尝试写reactnative的demo,下面是遇到的问题的记录
- native module
- ES6,import时如何正确使用花括号’{ }’
- React 中组件间通信的几种方式
- react-navigation
- react-navigation3 容易出的bug(实在不行 换回2吧)
- undefined is not an object (evaluating ‘RNGestureHandlerModule.State’解决方案
1
2
3
4
5remove node_modules and package-lock.json
npm install
npm install --save react-navigation
npm install --save react-native-gesture-handler
react-native link - unable to load script from asset/index.android.bundle问题解决
1
2
3mkdir android\app\src\main\assets
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
react-native run-android - could not get batchedbridge, make sure your bundle is packaged correctly
查看端口和ip是否正确 端口是否被占用
react中的refs
FlatList
animated
Warning: isMounted(…) is deprecated in plain Javascript Classes. Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks.
- 这是组件本身的bug 目前的解决方法是忽略
- import { YellowBox } from ‘react-native’;
- YellowBox.ignoreWarnings([‘Warning: isMounted(…) is deprecated’, ‘Module RCTImageLoader’]);
- 真机报错
- Could not connect to development server
- React—Native开发之 Could not connect to development server(Android)解决方法
- 启动另一个项目时失败,adb报错device still connecting
- React Native version mismatch 错误
- 简化启动夜神模拟器的步骤
部分错误是由于rn的版本问题。最好在初始化项目的时候指定版本号,目前0.55.4比较稳定
react-native bundle –platform android –dev false –entry-file index.android.js –bundle-output android/app/src/main/assets/index.android.bundle –assets-dest android/app/src/main/res