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.
-
46:39
The Bold Lib
1 day agoOwen Shroyer: BOLDTALK W/Angela Belcamino
2.92K10 -
7:57
Blackstone Griddles
1 day agoDouble Barrel Sausage Sandwich | Blackstone Griddles
7.3K1 -
32:24
Forrest Galante
11 hours agoHunting and Eating The World's WORST Fish (Everglades At Night)
99.2K5 -
32:10
Nikko Ortiz
15 hours agoSecret Agent Infiltrates Neo-Nazis...
13.6K15 -
15:04
MetatronGaming
1 day agoOriginal Commodore 64 VS C64 Maxi - Review and Comparison
22.5K7 -
9:46
MattMorseTV
14 hours ago $16.18 earnedTrump just SHUT DOWN a $287,000,000 FRAUD RING.
23.2K81 -
15:48
GritsGG
16 hours agoWinning a Rare Solos Prison End Game on Warzone!
17.8K1 -
11:37
The Pascal Show
16 hours ago $3.68 earnedTHEY WANT TO END HER?! Candace Owens Claims French President & First Lady Put A H*t Out On Her?!
17.4K19 -
LIVE
Lofi Girl
2 years agoSynthwave Radio 🌌 - beats to chill/game to
480 watching -
24:30
DeVory Darkins
17 hours agoMarjorie Taylor Greene RESIGNS as Minnesota dealt MAJOR BLOW after fraud scheme exposed
82.6K126