0 votes
129 views
by
Write the code making use of Hooks useState function that displays the number of times button named “CLICK” is clicked

1 Answer

0 votes
by (98.9k points)
 
Best answer
import React, { useState } from "react";

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

  const handleClick = () => {
    setCount(count + 1);
  };

  return (
    <div>
      <button onClick={handleClick}>CLICK</button>
      <p>You have clicked the button {count} times.</p>
    </div>
  );
}

export default App;

Related questions

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

557 users

...