Easy
How to Fix a Delayed Counter Update in React Using useState and setTimeout
Fill in the missing code to make this counter component work correctly. The current implementation doesn't update the display value as expected.
1function DelayedCounter() {2 const [count, setCount] = useState(0);34 const handleClick = () => {5 setTimeout(() => {6 // Missing code here7 _______________8 }, 1000);9 };1011 return (12 <div>13 <p>Count: {count}</p>14 <button onClick={handleClick}>15 Increment after 1 second16 </button>17 </div>18 );19}