Premium Only Content

Load React Component Data using useState and useEffect
The lesson goes over setting up a callback to React.useEffect to set the data for the messages in the chat room-like frontend application.
To make React be aware of any changes, the React.useState hook is used to keep track of the list of posted messages.
If you use a plain array of strings and set it to some initial values in the useEffect callback, React is not made aware of that change, so you don't see any update in the Document Object Model (DOM).
The way you react to changes in the application state, such as new messages populating an array, is by letting React know about that data. With the hook useState, you are given a function to mutate the state.
Calling the function to mutate the state that stores the message, React will render the component anew, reflecting the change in the elements of the array.
-
LIVE
Laura Loomer
1 hour agoEP136: YOU'RE FIRED! White House Vetting Crisis Continues
431 watching -
21:53
Glenn Greenwald
3 hours agoMichael Tracey on the Street: What Do People Think of the Epstein Case?
70.2K34 -
LIVE
DamnDanieI
1 hour agoKill First, Loot Later – OTG Live
339 watching -
LIVE
SpartakusLIVE
2 hours agoDuos w/ @GloryJean || #1 Masculine Muscle MASS sears YOUR retinas with MIND BENDING content
118 watching -
56:41
Donald Trump Jr.
5 hours agoLies, Leaks, and Lawfare: Censorship Corruption Exposed | TRIGGERED Ep.263
98.9K100 -
1:26:13
Mally_Mouse
4 hours agoLet's Hang!! -- P.O. Box & Chill!
1.54K -
1:02:37
BonginoReport
4 hours agoKamala Teases Book About Dumpster Fire Campaign - Nightly Scroll w/ Hayley Caronia (Ep.102)
47.3K34 -
35:05
Stephen Gardner
4 hours ago🔥Obama will be FORCED to Testify in Trump trial?
11.1K32 -
9:08
Tundra Tactical
1 hour agoTundra Tactical Political Memes Review!
4.46K -
LIVE
GloryJean
2 hours agoDuos w/ Spartakus 🔥 LOCK IN for Games w/ PASSION
22 watching