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.
-
49:01
Anthony Pompliano
2 days ago $0.35 earnedBitcoiners Built Tether Into The Most Profitable Company Ever
3.2K1 -
1:49:44
Russell Brand
4 days agoTerrence Howard’s SHOCKING New Theory of Reality - SF599
216K73 -
15:40
TimcastIRL
13 hours agoDemocrat Party Is DONE, Donors FLEE As Dems Face Approval Rating DISASTER
37.5K94 -
2:44:38
Laura Loomer
5 hours agoEP128: Iran's Nuclear Program Goes BOOM
129K115 -
3:20:44
Badlands Media
21 hours agoThe Narrative Ep. 27 - A Spectacular Success
91.8K9 -
1:21:56
Man in America
14 hours agoExposing Big Pharma’s #1 WEAPON for Keeping You SICK w/ Dr. Edward Group
55.8K19 -
15:53
Forrest Galante
20 hours agoPrivate Tour of India’s Best Secret Aquarium
121K11 -
5:44:01
Spartan
8 hours agoPro Halo Player | Sens Crisis Grind | Ranked Arena, Probably SWTOR at some point
54.7K -
2:38:46
vivafrei
15 hours agoEp. 269: U.S. Strikes Iran! Karen Read Verdict! Grace Schara Verdict! National Gaurd, SCOTUS & MORE!
234K418 -
3:50:55
FusedAegisTV
9 hours agoBatman Arkham Knight [4K + Mods] Hardest Difficulty ⋆ Western Re-tread
65.8K3