import React, { useState } from 'react';
import logo from './logo.svg';
import './App.css';
import Home from './Components/Home';
function App() {
console.log("Rendered")
let [count, setCount] = useState(0);
return (
<>
<h1>Hello World</h1>
</>
);
}
export default App;
Console Output:
Rendered
Rendered
我知道调用setCount方法会重新呈现App组件,但是使用useState钩子初始化计数状态是否会重新呈现App组件?