const { useState, useEffect, useMemo } = React;
const Home = () => {
const [count, setCount] = useState(0);
const [nowtime, setNowtime] = useState(0);
const sum = useMemo(() => ((1 + count) * count) / 2 + " ,random: " + Math.random(), [count]);
return (
<>
<p> count: {count}</p>
<p> sum: {sum}</p>
<p> nowtime: {nowtime}</p>
<button onClick={() => setCount(count + 1)}> add 1 </button>
<button onClick={() => setNowtime(Date.now())}> set now time </button>
</>
);
};
ReactDOM.render(<Home />, document.getElementById("app"));