What will be the output of the following code?
import React, { useState } from 'react';
function App() {
const [count, setCount] = useState(0);
return (
<div>
<h1>{count}</h1>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}
export default App;
The counter will increment by 2 each time.
The counter will increment by 1 each time.
The counter will stay the same.
The code will throw an error.
This question is part of this quiz :
Introduction to React