在使用自定義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’錯誤
}
};