调用useState是否可以重新渲染组件?

时间:2020-04-29 12:22:52

标签: reactjs react-hooks

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组件?

0 个答案:

没有答案