Answer the question
In order to leave comments, you need to log in
How to properly design a redux store structure?
Good afternoon. Help with a hollivar question.
The question is not entirely about the store, but rather about the form in which to store data in the repository, but it was necessary to title it somehow.
There is an entity for example toDo. For example, it comes to us from the server like this:
{
id: number;
text: string;
completed: boolean;
}
{
id: number;
text: string;
completed: boolean;
isSelected: boolean;
}
Answer the question
In order to leave comments, you need to log in
Of course, you don't need to modify the model.
The array with the id is also not very good.
The third option is to store the map, i.e. an object where keys are IDs and values isSelected.
A more correct option is WeakMap, where the keys are the objects of the body, but I do not know how friendly it is with redux.
In general, a common practice is to create a parallel entity state with the same keys, which contains the current ui state of the models.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question