We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
新版本的react的prop-type已经单独成包了,所以要先安装prop-types模块
npm install prop-types --save-dev
然后在组件中引入PropTypes模块
import React from 'react'; import PropTypes from 'prop-types';
class Skill extends React.Component { //code constructor(props) { super(props); // 设置 initial state this.state = { text: props.initialValue || 'Hello Wscats' }; } }
注意这里以前是React.PropTypes,现在为PropTypes
React.PropTypes
PropTypes
Skill.propTypes = { //定义传入props中的属性各种类型 initialValue: PropTypes.string.isRequired//PropTypes.string }; Skill.defaultProps = { //组件默认的props对象 initialValue: 'Hello Oaoafly' };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
新版本的react的prop-type已经单独成包了,所以要先安装prop-types模块
然后在组件中引入PropTypes模块
注意这里以前是
React.PropTypes
,现在为PropTypes
The text was updated successfully, but these errors were encountered: