dzintars / front

Test setup (Don't use!) Dev server URL available while i'm developing.
https://front.oswee.dev
1 stars 1 forks source link

Rename state `entities` and `ids` #57

Closed dzintars closed 4 years ago

dzintars commented 4 years ago

Conventions seems to be:

{
users : {
        byId : {
            "user1" : {
                username : "user1",
                name : "User 1",
            },
            "user2" : {
                username : "user2",
                name : "User 2",
            },
            "user3" : {
                username : "user3",
                name : "User 3",
            }
        },
        allIds : ["user1", "user2", "user3"]
    }
}

Source: https://redux.js.org/recipes/structuring-reducers/normalizing-state-shape

dzintars commented 4 years ago

Turns out >RTK (Redux Tool Kit) which kinda implements all best practices is recommending option entities and ids So.. i think it is worth to keep it that way. And it's easier to type.

Partial source: https://redux-toolkit.js.org/usage/usage-guide#sorting-entities Source 2: https://frontendmasters.com/courses/redux-mobx/state-store-selectors-with-reselect/ @ 2:00

dzintars commented 4 years ago

Closing this as i decided to use entities and ids naming convention.