What Is React Hooks?

 What is React Hooks In React Js.

Hooks state allow create state without writing a class components.before Hooks we can't write a lifecycle method in a function components
Its dosen't work inside class because its made for function bro.




import React, { useState } from "react";

function Count() {
    const [num, IncNum]=useState(50);
  function count() {
    IncNum(num-1);
  }
  return (
    <div>
      <h1>{num}</h1>
      <button onClick={count}>Click Me</button>
    </div>
  );
}
export default Count;




Comments