我正在处理下面的代码,一旦我添加了文本样式属性lineHeight: 1
,那么Flow类型检查工具会给出一个红色标记,上面写着:
“无法创建View
元素,因为属性lineHeight
在对象类型[1]中缺失,但存在于属性style
.Flow(InferError)中的对象文字[2]中”
如何解决这个错误?顺便说一句,错误没有来,我删除'lineHeight:1',如果删除它是没有意义的,而不是我的意图。
//Imports with Destructuring
// @flow
import { Text, View } from 'react-native';
import React from 'react';
//Prepare the contents
const Header = (props) => {
//Destructuring the styles
const { textStyle, viewStyle } = styles;
return (
<View style={viewStyle}>
<Text style={textStyle}>{props.headerText}</Text>
</View>
);
};
//Style the contents
const styles = {
viewStyle: {
backgroundColor: '#F8F8F8',
lineHeight:3,
alignItems: 'center',
height: 50,
paddingTop: 15,
position: 'relative'
},
textStyle: {
fontSize: 30,
color: '#3D407B',
fontWeight:'bold',
borderRadius: 3,
borderStyle:'solid',
},
myStyle: {
}
};
//Make them available to the app
export default Header;
lineHeight
支持文本不在视图中。