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

Function Exercise3

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

Source from the content-addressed store, hash-verified

1import React, { useState, useEffect } from 'react';
2
3function Exercise3() {
4 const [count, setCount] = useState(0);
5
6 useEffect(() => {
7 const interval = setInterval(() => {
8 setCount(prevCount => prevCount + 1);
9 }, 1000);
10
11 return () => clearInterval(interval);
12 }, []);
13
14 return <h1>{count}</h1>;
15}
16
17export default Exercise3;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected