Open crise1993 opened 1 month ago
同样问题+1,RN0.73(taro 4.0.7),翻了好些资料,我用安卓端调连报错是哪里都没打出来…推断原因是升级后expo依赖对不上号,只要引用react-native-device-info就会报错。需要修改scalePx2dp等引用到react-native-device-info的实现,对于expo ~50,依赖改为"expo-device": "^5.9.4"
,同时scalePx2dp的实现需改成类似如下:
import { Dimensions } from 'react-native';
// import DeviceInfo from 'react-native-device-info';
import { deviceType, DeviceType } from 'expo-device';
// 一般app 只有竖屏模式,所以可以只获取一次 width
const deviceWidthDp = Dimensions.get('window').width;
const deviceHeightDp = Dimensions.get('window').height;
let uiWidthPx = 375;
// if (DeviceInfo.isTablet()) {
// uiWidthPx = 750;
// }
if (deviceType === DeviceType.TABLET) {
uiWidthPx = 750;
}
不知道是否能采纳 @TheKonka
PS:RN和taro群加满了…哪里有渠道可以加进去…
相关平台
React Native
使用框架: React
复现步骤
1、下载https://github.com/crise1993/taro-rn-less代码之后 2、yarn install之后,运行yarn dev:rn命令 3、在index.less文件中加入font-size: 50px;会报错
期望结果
px能在rn环境中正确转换不会报错
实际结果
ERROR Error: react-native-device-info: NativeModule.RNDeviceInfo is null. To fix this issue try these steps: • For react-native <= 0.59: Run
react-native link react-native-device-info
in the project root. • Rebuild and re-run the app. • If you are using CocoaPods on iOS, runpod install
in theios
directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods. If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-device-info/react-native-device-info, js engine: hermes at Test (http://10.112.98.200:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.ganji.android.haoche&modulesOnly=false&runModule=true:125313:41) at RCTView at View at _View (http://10.112.98.200:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.ganji.android.haoche&modulesOnly=false&runModule=true:125017:47) at Index (http://10.112.98.200:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.ganji.android.haoche&modulesOnly=false&runModule=true:124947:76) at PageProvider (http://10.112.98.200:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.ganji.android.haoche&modulesOnly=false&runModule=true:109525:36) at RCTView at View at RCTScrollView at ScrollView环境信息
补充信息
试着升级和降级@tarojs/rn-style-transformer多个版本,都不好使。 顺便说一句: Taro.pxTransform在rn里面也不好使