Premium Only Content

Lecture No 1 React Hook useState() How its work and used. #reactjs #javascript #development
The useState() is a Hook that allows you to have state variables in functional components. so basically useState is the ability to encapsulate local state in a functional component. React has two types of components, one is class components which are ES6 classes that extend from React and the other is functional components. Class components a Component and can have state and lifecycle methods: class Message extends React. The useState hook is a special function that takes the initial state as an argument and returns an array of two entries. UseState encapsulates only a singular value from the state, for multiple states need to have useState calls.
Syntax: The first element is the initial state and the second one is a function that is used for updating the state.
const [state, setState] = useState(initialstate)
We can also pass a function as an argument if the initial state has to be computed. The value returned by the function will be used as the initial state.
const [sum, setsum] = useState(function generateRandomInteger(){5+7);})
The above function is an online function that computes the sum of two numbers and will be set as the initial state.
#javascript #reactjs #map #developer #development #hooks #javascriptengineer
-
12:14:58
Spartan
15 hours agoSpartan - Pro Halo Player for OMiT | Scrims vs C9 then ranked
57.6K6 -
2:16:19
vivafrei
18 hours agoEp. 273: Russia Hoax CONFIRMED! Will ARRESTS Follow? Trump SUES WSJ! Epstein Docs Release? & MORE!
151K165 -
4:15:15
EricJohnPizzaArtist
6 days agoAwesome Sauce PIZZA ART LIVE Ep. #55: Wendy Wild!
52.1K2 -
11:54
Tundra Tactical
11 hours ago $7.36 earnedIf You Laugh at These Gun Memes, the ATF Gets Your Dog – Tundy Meme Review
64.6K2 -
4:08:53
Cewpins
7 hours agoSunday Sesh🍃weed💨420🔥!Giveaway !mj
24K11 -
2:05:32
Nerdrotic
10 hours ago $3.72 earnedForbidden Inventions and Shadow Cover-ups | Forbidden Frontier #109
47.9K6 -
2:57:01
JahBlessGames
7 hours ago🎉THPS w/ Cheap | Variety Ting | Music too??
10.1K1 -
3:21:46
Barry Cunningham
17 hours agoPRESIDENT TRUMP HAS EXPOSED BARACK OBAMA AS A TRAITOR! AND MORE NEWS!
60.7K123 -
2:19:12
THOUGHTCAST With Jeff D.
7 hours ago $0.05 earnedLATE NIGHT FORTNITE. Game & News Chat with Jeff D.
5.17K -
5:31:41
Cancel This Podcast
8 hours ago $0.86 earnedDRAGON QUEST X ONLINE VERSION 5.1: SUPER DEMON WORLD WAR! - CTP Gaming!
10.4K