Error : Component [ComponentName] declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?

Error : Component [ComponentName] declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?

有人可以解释为什么我在导入 PropTypes 时出现此错误:

Component 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;

在定义 propTypes 时,您应该使用驼峰式而不是标题式。

这样做:

CustomBackground.propTypes = {...}

而不是

CustomBackground.PropTypes = {...}