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.
-
30:29
DeVory Darkins
1 day ago $4.42 earnedtroubling FBI report details the shooter left chilling note as more Democrats suffer humiliation
6.7K76 -
1:50:29
Tucker Carlson
6 hours agoTucker Carlson LIVE: America After Charlie Kirk
314K288 -
2:12:05
FreshandFit
6 hours agoIf She Can Do Better She Will Leave You
33.8K11 -
2:14:00
Inverted World Live
8 hours agoLegion of Zoom | Ep. 109
207K10 -
2:42:57
TimcastIRL
9 hours agoDOJ Releases Charlie Kirk Assassin Messages, Trans Left Aligned Confirmed | Timcast IRL
350K207 -
1:09:13
Man in America
12 hours agoSICK: Xi & Putin Caught Plotting Organ Transplants for “Eternal Life”
86.3K29 -
6:04:35
Drew Hernandez
14 hours agoMASS CONFUSION AROUND CHARLIE'S MURDER
68K51 -
1:01:40
HotZone
6 days ago $12.84 earned"Prepare for WAR" - Confronting the URGENT Threat to America
84.9K22 -
20:23
Scammer Payback
14 hours agoTerrifying Scammers with File Deletions
49.7K13 -
16:22
The Gun Collective
11 hours agoWOW! 17 New Guns JUST GOT RELEASED!
71K11