React Hooks —

React Hooks are new addition to react 16.8,

The Hooks allowed us to use to state and other features without declaring class

example of hooks

Const [number, setNumber] = useState(0)

here we declare const number which takes initial argument of number zero ,

and to update this state we will use the following syntax – >

<button onClick={() => setNumber(number + 1)}>

to show the value of this state we will use

<p> The Current Number is {number} </p>

React Hooks also allow us to declare multiple state variables and use state hook more than once in single component

it is skips the creation of class

Leave a comment