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

Function Counter

mini-react/src/index.jsx:3–21  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

1const { render, useState, useEffect } = window.MiniReact;
2
3function Counter(props) {
4 const {
5 initialNum,
6 interval
7 } = props;
8
9 const [count, setCount] = useState(initialNum)
10
11 useEffect(() => {
12 const timer = setInterval(() => {
13 setCount((count)=> count + 1)
14 }, interval);
15 return () => clearTimeout(timer);
16 }, []);
17
18 return <div>
19 <p>{count}</p>
20 </div>;
21}
22
23function App() {
24 return <Counter interval={1000} initialNum={10}></Counter>

Callers

nothing calls this directly

Calls 2

useStateFunction · 0.85
useEffectFunction · 0.85

Tested by

no test coverage detected