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

Function Exercise5

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

Source from the content-addressed store, hash-verified

1import React, { useState } from 'react';
2
3function Exercise5() {
4 const [state, setState] = useState({ count: 0 });
5
6 const incrementCount = () => {
7 setState(prevState => ({
8 count: prevState.count + 1
9 }));
10 setState(prevState => ({
11 count: prevState.count + 1
12 }));
13 };
14
15 return (
16 <div>
17 <button onClick={incrementCount}>Increment</button>
18 <h1>{state.count}</h1>
19 </div>
20 );
21}
22
23export default Exercise5;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected