I would like to hear opinions on structuring the redux store for the case when you need to keep a list of items and the selected item.
Example. Given a list of elements and individual elements on the same page. The user should be able to select an item from the list. When an item is selected, details of this must be loaded. When the selected item is updated, it must also be updated in the details and in the list (for example, if the item name is changed, it must also be visible in the list). All data must be retrieved from the backend, and the item model in the list is different from the selected item model. An item in the list has fewer properties / details. The selected item contains additional information about the data.
What do you think is the best way to structure storex in this case? I tried to use Google examples, but as a rule, in all examples in the list of elements and the selected element are considered the same, and there is no need to store a separate object for the detailed element.
I tried a simple approach. Just save the list of items and the selected item in the store:
storeExample = { items: { 1: item1, 2: item2, 3: item3 } selectedItem: detailedItem1 };
Is there a better way to structure a store? I hope that the question will make sense, as it is a little difficult to explain my problems. Any "live" examples will be appreciated.
source share