💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
``` ReferenceError: propTypes is not defined ``` ``` profile.jsx ``` ``` import React from 'react'; import PropTypes from 'prop-types'; class Profile extends React.Component{ render(){ return ( <div className="profile-component"> <h1>我的名字{this.props.name}</h1> <h2>我今年{this.props.age}</h2> </div> ) } } Profile.propTypes = { name:PropTypes.string.isRequired, age:PropTypes.number.isRequired } Profile.PropTypes = propTypes; export default Profile; ``` ``` import React from 'react'; import PropTypes from 'prop-types'; class Profile extends React.Component{ render(){ return ( <div className="profile-component"> <h1>我的名字{this.props.name}</h1> <h2>我今年{this.props.age}</h2> </div> ) } } const propTypes = { name:PropTypes.string.isRequired, age:PropTypes.number.isRequired } Profile.PropTypes = propTypes; export default Profile; ``` ``` import React from 'react'; import PropTypes from 'prop-types'; class Profile extends React.Component{ render(){ return ( <div className="profile-component"> <h1>我的名字{this.props.name}</h1> <h2>我今年{this.props.age}</h2> </div> ) } } Profile.propTypes = { name: PropTypes.string, age: PropTypes.number, // ... define your prop validations }; //Profile.PropTypes = propTypes; export default Profile; ```