是的!与此相关的问题和答案很多,但是在每个解决方案中,所有人都说要用View.propTypes.style
代替ViewPropTypes.style
。但是在我的项目中,整个项目中没有View.propTypes.style
代码可用。
如果在我的项目中View.propTypes.style
不可用,那我可以在哪里替换?
完整错误:
undefined is not an object (evaluating 'a.View.propTypes.style')
[fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: undefined is not an object (evaluating 'a.View.propTypes.style')
[290:10014] Unhandled JS Exception: undefined is not an object (evaluating 'a.View.propTypes.style')
[290:10014] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: undefined is not an object (evaluating 'a.View.propTypes.style')', reason: 'Unhandled JS Exception: undefined is not an object (evaluating 'a.View.prop..., stack:
<unknown>@1022:1541
t@2:620
作为参考,我在下面使用了propTypes
,但我认为这不是问题。
const propTypes = {
data: PropTypes.array,
onChange: PropTypes.func,
initValue: PropTypes.string,
style: ViewPropTypes.style,
selectStyle: ViewPropTypes.style,
optionStyle: ViewPropTypes.style,
optionTextStyle: Text.propTypes.style,
sectionStyle: ViewPropTypes.style,
sectionTextStyle: Text.propTypes.style,
cancelStyle: ViewPropTypes.style,
cancelTextStyle: Text.propTypes.style,
overlayStyle: ViewPropTypes.style,
cancelText: PropTypes.string
};