javascript - React-Native:Native-base:失败的道具类型:提供给“View”的无效 props.style 键“NativeBase”
问题描述
版本:
反应:16.3.1
反应原生:~0.55.2
本机基础:^2.8.0
问题:警告:道具类型失败:提供给“视图”的道具样式键“NativeBase”无效
平台:iOS & Android
每当我将本机基础集成到项目中时,我都会在 react-native 项目中收到此警告。
这是此代码。
import {
View,
TouchableHighlight,
StyleSheet,
Image,
Dimensions,
ScrollView,
SafeAreaView
} from "react-native";
import { Button, Text } from "native-base";
<ScrollView>
{props.detail.site_url !== '#' ? (
<View style={styles.visitButton}>
<TouchableHighlight>
<Button
success
onPress={() => props.visitSite(props.detail.site_url)}
>
<Text>{props.detail.name}</Text>
</Button>
</TouchableHighlight>
</View>
) : (
<View></View>
)}
</ScrollView>
const styles = Stylesheet.create({
visitButton: {
flex: 1,
marginVertical: 20,
display: 'flex',
justifyContent: 'center',
alignItems: 'center'
}
})
解决方案
您正在使用的库中的文件似乎存在问题。
他们将一个样式嵌套在另一个样式中,从而导致了这个警告。您可以在您提供的屏幕截图中看到这一点:
{
"borderRadius": 5,
"NativeBase": {
// NativeBase block
},
},
"Icon": {
// Icon block
},
“NativeBase”块不应嵌套到另一个块中,它应与“Icon”处于同一级别,如下所示:
{
"borderRadius": 5,
},
"NativeBase": {
// NativeBase block
},
"Icon": {
// Icon block
},
要修复它,您可以手动更改库中的文件或等待自动修复并在此时更新 native-base。
推荐阅读
- java - Spring Batch - 保持服务器运行
- swift - 从 MTLTexture (Swift, macOS) 制作 CGImage 时的内存泄漏
- c++ - C++中赋值运算符重载函数的正确使用?
- ios - 如何将 URL 数组转换为字符串数组?
- javascript - Google Maps API - 缩放按钮不响应鼠标点击
- jquery - asp.net 使用 jQuery 一次将多个数据发布到多个表中
- python - 如何计算python中每一行上具有值的列数?
- c# - 构造函数参数过多的 Unity 注入
- javascript - 构建命运之轮游戏,我试图让按键事件来检测随机单词数组中的一个字母
- c - 处理错误的文件输入名称。使用错误名称从 argv 读取 i 文件时程序崩溃。C 编程