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
TimcastIRL
3 hours agoJimmy Kimmel Show IN CHAOS Before Return, Affiliates REFUSE, Staff Says THEYLL QUIT
9,724 watching -
LIVE
Laura Loomer
3 hours agoEP145: Trump Makes BOMBSHELL Autism Announcement
867 watching -
LIVE
SpartakusLIVE
4 hours agoEXPLOSIVE 2v2 Tuesday has viewers GLUED to the screen
500 watching -
LIVE
GrimmHollywood
3 hours ago🔴LIVE • GRIMM'S TUESDAY FRIGHT NIGHT • STARRING GRIMM HOLLYWOOD • NO, I'M NOT HUMAN PART 1 •
103 watching -
LIVE
Flyover Conservatives
10 hours agoAI Encouraged Suicide: The Global Experiment on Our Kids - Joe Allen | FOC Show
305 watching -
1:07:40
Glenn Greenwald
4 hours agoTucker Carlson on Charlie Kirk Assassination Fallout, Free Speech, Foreign Policy, and the Reaction to his Kirk Remarks | SYSTEM UPDATE #520
149K102 -
14:22
Robbi On The Record
2 days ago $0.20 earnedGen Z’s Narcissism Obsession: Why Everyone’s a “Psychologist”
19K8 -
LIVE
GritsGG
5 hours agoQuad Win Streaks!🫡 Most Wins in WORLD! 3600+
204 watching -
1:09:28
Sarah Westall
3 hours agoCan the World Be This Strange? The Nature of Our Reality w/ Darius J Wright
20.7K -
megimu32
3 hours agoOn The Subject: Friends | 31 Years of the Sitcom That Defined a Generation
27.1K4