Posts

type of hooks in react

In React, there are several types of built-in hooks to handle different behavior of the components. Here is a list of commonly used built-in hooks. 1. State Hooks: ‘useState’:  It is the most commonly used React Hook. It allows functional components to have state variables. It takes an initial state value as the argument and returns an array with two elements — the current state value and a function to update that state. import React , { useState } from 'react' ; function Counter () { const [count, setCount] = useState ( 0 ); const increment = () => { setCount (count + 1 ); }; return ( <div> <p>Count: {count}</p> <button onClick={increment}>Increment</button> </div> ); } ‘useReducer’:  Provides an alternative to  ‘useState’  for managing complex state logic involving multiple sub-values or when the next state depends on the previous one. import React , { useReducer } from 'react' ; const

Reactjs class-1