gpt4 book ai didi

react-native - undefined 不是一个对象(评估'_reactNative.Text.defaultProps.allowFrontScaling)

转载 作者:行者123 更新时间:2023-12-05 08:52:59 45 4
gpt4 key购买 nike

尝试在 android 上加载应用程序以响应 native 时出现此问题(它适用于 ios)

导入 'react-native' 似乎不起作用。我已经运行了 npm install

这是导致错误的文件:

import { Text } from 'react-native'
import DebugConfig from './DebugConfig'
import AppConfig from './AppConfig'

// Allow/disallow font-scaling in app
Text.defaultProps.allowFontScaling = AppConfig.allowTextFontScaling

if (__DEV__) {
// If ReactNative's yellow box warnings are too much, it is possible to turn
// it off, but the healthier approach is to fix the warnings. =)
console.disableYellowBox = !DebugConfig.yellowBox
}

最佳答案

在 React Native 0.57.5 上测试

Text.defaultProps.allowFontScaling 在 0.57.5 中未定义所以我尝试了以下一个。

Text.defaultProps = Text.defaultProps || {};
Text.defaultProps.allowFontScaling = false;

关于react-native - undefined 不是一个对象(评估'_reactNative.Text.defaultProps.allowFrontScaling),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54909798/

45 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com