React 学习(二) 类组件的props
super
-
super(props): Superclass will help you to keep the props:[^props]
import React, { Component } from "react"; export default class App extends Component { constructor(props) { super(props); } render() { return ( <div>App</div> ); } }
-
But we use super() also can run
import React, { Component } from "react"; export default class App extends Component { constructor() { super(); } render() { return ( <div>App</div> ); } }
-
Subclass will auto execute the constructor function, we can not write it
import React, { Component } from "react"; export default class App extends Component { render() { return ( <div>App</div> ); } }
每天进步一点点