Question from the Next.js test

What will be logged in the console when the button is clicked?

Hard

What will the following code display in the console when the button is clicked?

import React, { useState } from 'react';

function Counter() {
  const [count, setCount] = useState(0);

  const handleClick = () => {
    setCount(count + 1);
    setCount((prevCount) => prevCount + 1);
    console.log(count);
  };

  return (
    <div>
      <p>Counter: {count}</p>
      <button onClick={handleClick}>Increment</button>
    </div>
  );
}

export default Counter;
Author: ilyassStatus: PublishedQuestion passed 65 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!