Premium Only Content

Generate Div for Every Message in Array in React App
Learn how to build a message board or chat room kind of app in the JavaScript programming language using the React library for the frontend.
In this lesson we start building the list of messages using the dynamic generation of div elements according to an array of strings that contain each message content.
The lesson returns a JSX template (that looks like HTML) from a React function component that displays a box container with chat messages.
You assign a class attribute to an element in React by defining the prop className.
You can make an array — a sequence of things, in this case of strings — to hold the value of each message. Then you use the Array.prototype.map function to make a div for each string.
Interpolation in JSX can be performed by surrounding the name of a variable with curly braces. Otherwise, without curly braces, the literal characters that compose the variable name are shown.
-
17:21
Actual Justice Warrior
15 hours agoProtester MELTS DOWN Over ICE Bus
72713 -
LIVE
RalliedLIVE
15 hours ago $15.71 earned24 HOUR BIRTHDAY STREAM
3,418 watching -
1:17:28
Surviving The Survivor: #BestGuests in True Crime
15 hours agoLIVE Bryan Kohberger Hearing: Judge Deciding on Trial Delay & Media Leaks
241 -
21:58
Rand Paul
13 hours agoDr. Rand Paul Joins Tim Pool on Timcast
9.38K11 -
24:47
DeVory Darkins
1 day ago $4.66 earnedDemocrats dealt MASSIVE BLOW after Political Stunt BACK FIRES leads to arrest
23.9K100 -
LIVE
Lofi Girl
2 years agolofi hip hop radio 📚 - beats to relax/study to
869 watching -
10:58
MattMorseTV
16 hours ago $2.86 earnedLindsey Graham just got EXPOSED.
6.8K42 -
2:21:35
FreshandFit
7 hours agoAfter Hours w/ Zherka & Mr Organik
237K55 -
2:20:12
Badlands Media
15 hours agoDevolution Power Hour Ep. 364: False Flags, Factions & the Fight for the Future
98.3K33 -
2:02:46
Inverted World Live
8 hours agoCan Whales Teach Us to Talk to Aliens | Ep.61
94.5K7