React Hooks Tutorial -2 - useState with object

preview_player
Показать описание
What is a Hook?
A Hook is a special function that lets you “hook into” React features. For example, useState is a Hook that lets you add React state to function components. We’ll learn other Hooks later.

When would I use a Hook?
If you write a function component and realize you need to add some state to it, previously you had to convert it to a class. Now you can use a Hook inside the existing function component.

what is useState hook ?

useState is a Hook that allows you to have state variables in functional components. You pass the initial state to this function and it returns a variable with the current state value (not necessarily the initial state) and another function to update this value.

Declaration :
import React, { useState } from 'react';
Syntax:
const [variable ,function]=useState(initialValue)

#jasacadamy #hook #useState
Рекомендации по теме