Understanding Redux #1 by Ohans Emmanuel
Author:Ohans Emmanuel
Language: eng
Format: epub
Published: 2020-10-20T00:00:00+00:00
{ text: "Hello there. U good?", is_user_msg: false }
Now, representing the messages field within the state with an object, we should have something like this:
messages: { user_id: { text, is_user_msg }, user_id_2: { text, is_user_msg } }
Notice how Iâm also using an object instead of an array again. Also, weâre going to map each message to the unique key, user_id of the contact.
This is because a user can have different conversations with different contacts, and it is important to show this representation within the state object. For example, when a contact is clicked, we need to know which was clicked! How do we do this? Yes, with their user_id.
The representation above is incomplete but weâve made a whole lot of progress! The messages field weâve represented here assumes that each contact (represented by their unique user id) has only one message.
But, thatâs not always the case. A user can have many messages sent back and forth within a conversation.
So how do we do this?
The easiest way is to have an array of messages, but instead, Iâll represent this with objects.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Goal (Off-Campus #4) by Elle Kennedy(13178)
Kathy Andrews Collection by Kathy Andrews(11290)
Diary of a Player by Brad Paisley(7243)
What Does This Button Do? by Bruce Dickinson(5923)
Assassin’s Fate by Robin Hobb(5839)
Big Little Lies by Liane Moriarty(5495)
Altered Sensations by David Pantalony(4845)
Pale Blue Dot by Carl Sagan(4591)
Sticky Fingers by Joe Hagan(3895)
The Death of the Heart by Elizabeth Bowen(3321)
The Heroin Diaries by Nikki Sixx(3302)
Beneath These Shadows by Meghan March(3132)
Confessions of a Video Vixen by Karrine Steffans(3088)
The Help by Kathryn Stockett(3004)
How Music Works by David Byrne(2944)
Jam by Jam (epub)(2866)
Harry Potter 4 - Harry Potter and The Goblet of Fire by J.K.Rowling(2786)
Strange Fascination: David Bowie: The Definitive Story by David Buckley(2694)
Petty: The Biography by Warren Zanes(2566)
