MCPcopy Create free account
hub / github.com/CodeWithHarry/Sigma-Web-Dev-Course / App

Function App

video 117/src/App.jsx:15–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14
15function App() {
16 const [count, setCount] = useState(0)
17 const [numbers, setNumbers] = useState(nums)
18
19 // const magical = numbers.find(item=>item.isMagical===true) // Expensive Computation
20 const magical = useMemo(() => numbers.find(item=>item.isMagical===true), [numbers])
21
22 return (
23 <>
24 <div>
25 <span>Magical number is {magical.index}</span>
26 <a href="https://vitejs.dev" target="_blank">
27 <img src={viteLogo} className="logo" alt="Vite logo" />
28 </a>
29 <a href="https://react.dev" target="_blank">
30 <img src={reactLogo} className="logo react" alt="React logo" />
31 </a>
32 </div>
33 <h1>Vite + React</h1>
34 <div className="card">
35 <button onClick={() => {
36 setCount((count) => count + 1);
37 if(count == 10){
38 setNumbers(new Array(10_000_000).fill(0).map((_, i)=>{
39 return {
40 index: i,
41 isMagical: i===9_000_000
42 }
43 }))
44 }
45
46 }}>
47 count is {count}
48 </button>
49 <p>
50 Edit <code>src/App.jsx</code> and save to test HMR
51 </p>
52 </div>
53 <p className="read-the-docs">
54 Click on the Vite and React logos to learn more
55 </p>
56 </>
57 )
58}
59
60export default App

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected