赞助

https://react.docschina.org/docs/hooks-intro.html

Hook 是 React 16.8 的新增特性。它可以让你在不编写 class 的情况下使用 state 以及其他的 React 特性。

import React, { useState } from 'react';

 

function Example() {

  const [count, setCount] = useState(0);

  return (

    <div>

      <p>You clicked {count} times</p>

      <button onClick={() => setCount(count + 1)}>

        Click me

      </button>

    </div>

  );

}

 

 

状态数据和UI显示分离

 

 

useEffect

 

posted on 2021-08-21 19:50  Tsunami黄嵩粟  阅读(17)  评论(0编辑  收藏  举报