有人可以解释为什么我在导入PropTypes时会出现此错误:
组件CustomBackground声明了PropTypes
而不是propTypes
。是否拼错了属性赋值?
CustomBackground.js:
import PropTypes from 'prop-types';
const CustomBackground=({children})=>(
<ImageBackground source={background} style={styles.imagebackground}>
{children}
</ImageBackground>
)
CustomBackground.PropTypes={
children:PropTypes.element.isRequired,
}
export default CustomBackground;
字符串
2条答案
按热度按时间gev0vcfq1#
在定义propType时,应使用camelCase而不是TitleCase。
这样做:
字符串
而不是
型
goucqfw62#
这里是完整的代码
字符串