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
The Quartering
1 hour agoWhat's Even Happening Anymore...
6,250 watching -
LIVE
Dr Disrespect
4 hours ago🔴LIVE - DR DISRESPECT - ARC RAIDERS - NORTH LINE UPDATE
1,622 watching -
30:28
The White House
4 hours agoPresident Trump and the First Lady Participate in an Executive Order Signing
1.53K6 -
1:13:56
DeVory Darkins
2 hours agoNewsom SUFFERS MAJOR SETBACK after Trump revokes 17,000 Commercial Drivers Licenses
121K48 -
1:07:32
Timcast
3 hours agoDemocrats CAUGHT Framing Trump On Epstein, Leaked Emails Show Journalist COLLUSION :+1: 1
138K168 -
LIVE
The Bold Lib
55 minutes agoBOLDCHAT: Moms For Liberty | Free Speech w/ANGELA BELCAMINO
21 watching -
2:11:09
Steven Crowder
5 hours ago🔴 Just Release the Damn Epstein Files - End It Once and For All
420K303 -
10:06
VSOGunChannel
2 hours ago $0.08 earnedCongress Tells ATF to Stop Doing the National Firearms Act
611 -
30:40
The Boomer Effect
17 hours agoNo More Beardos
1 -
1:08:00
Sean Unpaved
3 hours agoMike Vrabel Has Restored The Patriot Way! | UNPAVED
15.1K2