MCPcopy Create free account
hub / github.com/QuarkGluonPlasma/react-course-code / Demo

Function Demo

ahooks-hook/src/App5.tsx:4–22  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

2import React, { useState } from 'react';
3
4const Demo: React.FC<{ count: number }> = (props) => {
5 const [randomNum, setRandomNum] = useState(Math.random());
6
7 useWhyDidYouUpdate('Demo', { ...props, randomNum });
8
9 return (
10 <div>
11 <div>
12 <span>number: {props.count}</span>
13 </div>
14 <div>
15 randomNum: {randomNum}
16 <button onClick={() => setRandomNum(Math.random)}>
17 设置随机 state
18 </button>
19 </div>
20 </div>
21 );
22};
23
24export default () => {
25 const [count, setCount] = useState(0);

Callers

nothing calls this directly

Calls 2

useStateFunction · 0.90
useWhyDidYouUpdateFunction · 0.90

Tested by

no test coverage detected