When we use vUE, we pass values to components like this. For example, if we have an item.vue component inside this component, we are receiving data in props, and specifying the type and default values of the values in type and value in count

<template>
  <div>{{count}}</div>
</template>

<script>
export default {
  props: {
  	count: {
		type: Number,
  		value: 0
	}
  },
  created(){
	
  }
}
</script>
Copy the code

React (16.x) doesn’t work this way. Instead, use default and propTypes to initialize default values and type checks

To use PropTypes, install with NPM: NPM install prop-types

import React, { Component } from 'react' import PropTypes from 'prop-types' class Counter extends Component { constructor(props){ Super (props) this.state = {}} // When there is no props, we should initialize initCount with a default value. Static default = {initCount: Static propTypes = {initCount must be number initCount: PropTypes.number } render() { return( <div> <input style={{marginTop: '30px'}} type="button" value="+1"/> <pCopy the code

Now that we have specified that initCount must be a numeric value, what about passing a string