AbhayVel / yogesh911

0 stars 0 forks source link

what is useState in react? #46

Open YogeshG85 opened 1 year ago

YogeshG85 commented 1 year ago

In React, useState is a built-in hook that allows you to add state to a functional component. State is a way to store and manage data within a component. The useState hook takes an initial state value and returns an array with two elements:

  1. The first element is the current state value.
  2. The second element is a function that can be used to update the state.

`mport React, { useState } from 'react';

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

function handleIncrement() { setCount(count + 1); }

return (

Count: {count}

); }`