Let's say I have a reducer with the following state:
messages: [
{
"id": "94",
"characterId": "1",
"text": "Uhm... Who are you?",
"cloneId": "",
"parentId": ""
},
{
"id": "92",
"characterId": "1",
"text": "So what's with the whole E=mc2 thing?",
"cloneId": "",
"parentId": ""
},
{
"id": "68-1",
"characterId": "1",
"text": "Oh no. Even now, we only have a small glimpse of the bottom of the ocean!",
"cloneId": "",
"parentId": "68"
}
]
How can I make the Message component representing the message with id "92" rerender only when say the object with id "92" is updated?
This approach causes a rerender whenever any of the objects in the array change :/
const Message = () => {
const data = useSelector((state) => state.conversationsData.messages.find((m) => {
return m.id == '92'
}))
...
}