📜  反应中的 useref - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:27.943000             🧑  作者: Mango

代码示例6
import { useRef } from 'react';

function LogButtonClicks() {
  const countRef = useRef(0);  
  const handle = () => {
    countRef.current++;    console.log(`Clicked ${countRef.current} times`);
  };

  console.log('I rendered!');

  return ;
}