What do you understand by Hooks in ReactJS?

Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class. Hooks are backwards-compatible. Let’s understand with an example -

import React, { useState } from ‘react’;

function Example() {
// Declare a new state variable, which we’ll call “count”
const [count, setCount] = useState(0);

return (


You clicked {count} times


<button onClick={() => setCount(count + 1)}>
Click me


);
}

Here, useState is a Hook which is used in the above example.