React by value, type, and default value of the verification value

const ele = <Ff const = { 'ha'} index = {55}> </ Ff>
let box = document.querySelector('#app')
// console.log(box)
// mount
render (he, box)

  

import React,{Component} from 'react'
import PropTypes from 'prop-types'

export default  class ClickS extends React.Component {
  constructor (props) {
    super(props)
    this.state= {
      msg: '123'
    }
    console.log(this.props)
  }
  render () {
    return <div>
  <h2>{this.state.msg}------{this.props.index}---{this.props.const}---{this.props.name}</h2>
    </div>
  }

ClickS.propTypes = {
  const: PropTypes.string.isRequired, // denotes must pass, whose type is String 
 index: PropTypes.number
}

  It is a proven method // func representation

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

 If no value is passed, to which a default value

ClickS.defaultProps = {
  name: 'John Doe'
}

  

 

 

 

 

Guess you like

Origin www.cnblogs.com/js-liqian/p/11829071.html