import { useMemo, useState } from 'react';

function LearnUseMemo() {
  let [count, setCount] = useState(0);

  let doubleCount = useMemo(() => count * 2, [count]);

  return (
    <div>
      <p>计数的2倍：{count * 2}</p>
      <p>计数的2倍：{doubleCount}</p>

      <p>
        <button
          onClick={() => {
            setCount((prevState) => prevState + 1);
          }}
        >
          +
        </button>
      </p>
    </div>
  );
}

export default LearnUseMemo;
