函數式組件
// 創建函數式組件
function MyComponent() {
console.log(this)//this undefined 因為Babel開啟了 嚴格模式
return <h1>我是用函數定義的組件</h1>
}
//渲染虛擬DOM
ReactDOM.render(<MyComponent/>,document.getElementById("container"))
函數式組件
// 創建函數式組件
function MyComponent() {
console.log(this)//this undefined 因為Babel開啟了 嚴格模式
return <h1>我是用函數定義的組件</h1>
}
//渲染虛擬DOM
ReactDOM.render(<MyComponent/>,document.getElementById("container"))