加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

用于文本样式的react-native prop类型

发布时间:2020-12-15 05:06:19 所属栏目:百科 来源:网络整理
导读:我有一个结构简单的组件和一个 Text我希望以一种风格传递到树中的某个地方.这对于proptypes验证非常有效. 基本设置不仅仅是这个 export default class Component extends PureComponent { render() { return (ViewText style={this.props.style}Some text/Te
我有一个结构简单的组件和一个< Text>我希望以一种风格传递到树中的某个地方.这对于proptypes验证非常有效.

基本设置不仅仅是这个

export default class Component extends PureComponent {
    render() {
        return (<View><Text style={this.props.style}>Some text</Text></view>);
    }
}

Component.defaultProps = {
    style: null,};

Component.propTypes = {
    style: ViewPropTypes.style,};

问题是ViewPropTypes.style不包含ie颜色键.因此,提供带有颜色的样式无效并产生警告.我尝试导入TextStylePropTypes,就像我在https://github.com/facebook/react-native/blob/master/Libraries/Text/TextStylePropTypes.js中找到的那样,但它是未定义的.

关于该怎么做的任何建议?

对于任何试图实现这一点的人来说,似乎不推荐使用View.propTypes.style,而不支持Text.propTypes.style.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读