For example

<! DOCTYPEhtml>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="Width = device - width, initial - scale = 1.0">
    <title>Document</title>
</head>
<body>
    <! -- Get the container ready -->
    <div id="test"></div>
    <! Import dependencies, import dependencies, must follow this step -->
    <script type="text/javascript" src=".. /js/react.development.js"></script>
    <script type="text/javascript" src=".. /js/react-dom.development.js"></script>
    <script type="text/javascript" src=".. /js/babel.min.js"></script>
    
    <! -- JSX syntax is parsed with Babel
    <script type="text/babel">
        // 1. Create components
        class Weather extends React.Component{
            constructor(props){
                super(props)
                this.state={
                    isHot:true}}render(){
                console.log(this)
                // this.state={
                // isHot:true
                // }
                const {isHot} = this.state
                return (
                    <h1>The weather isHot today. 'Hot ':' cool '}</h1>)}}// 2. Render. If there are multiple renders of the same container, the later ones will overwrite the previous ones
        ReactDOM.render(<Weather/>.document.getElementById('test'))
    </script>
</body>
</html>
Copy the code

parsing

  1. The React Component builds on the React Component class. React creates a Weather instance that passes properties like state and props

If class A inherits from class B and A uses A constructor, the constructor of class A must call super().

  1. The Weather instance inherits properties such as state, which can be changed directly in the constructor