React Native 自定义组件报错 has no propType for native prop

前端之家收集整理的这篇文章主要介绍了React Native 自定义组件报错 has no propType for native prop前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在使用自定义UI组件时,定义JS组件报如下错误

has no propType for native prop.

If you haven't changed this prop yourself,this usually means that your versions of the native code andr JavaScript code are out of sync. Updating both should make this error go away.

解决办法就是在定义js组件属性时,加…View.propTypes

var VideoView = {
    name:'VideoView',propTypes:{
        style: View.propTypes.style,source:PropTypes.shape({
            url:PropTypes.string,headers:PropTypes.object,}),...View.propTypes,//包含默认的View的属性,如果没有这句会报‘has no propType for native prop’错误
    }
};
原文链接:https://www.f2er.com/react/305887.html

猜你在找的React相关文章