MCPcopy Create free account
hub / github.com/coolvasanth/reactjs_interview_preparation / Exercise9

Function Exercise9

src/HardQuestions/Exercise9.js:3–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import React, { useState, useEffect } from 'react';
2
3function Exercise9() {
4 const [count, setCount] = useState(0);
5
6 useEffect(() => {
7 function handleResize() {
8 setCount(count + 1);
9 console.log('screen resized', count);
10 }
11
12 window.addEventListener('resize', handleResize);
13
14 return () => {
15 window.removeEventListener('resize', handleResize);
16 };
17 }, []);
18
19 return <h1>{count}</h1>;
20}
21
22export default Exercise9;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected