I
I
Ilya2016-07-07 17:27:44
React
Ilya, 2016-07-07 17:27:44

Redux: where to add extra. data?

The list of groups is stored in state

class group {
    constructor(id, name, messagesCount) {
        this.id = id;
        this.name = name;
        this.messagesCount = messagesCount;
    }
}
groups: [group1, group2, group3]

On the page I show this list and all its data. But you can go to the page of the group, where more messages from this group will be loaded.
How should these messages be stored?
Find the selected group in the groups list and add it there as group1.messages?
Or make a separate reducer that will store as an object
{
  id1: messages,
  id2: messages,
  id3:messages
}

There won't be too many posts. On average 100, maximum 500. And there will be 1-3 groups.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Makarov, 2016-07-07
@FireGM

I try to store all data in a tree (where relationships between entities are strictly vertical) to avoid link invalidation. I vote for group.messages

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question