Redux UI state in objects

I use normalizrand have a branch state.entities.users.

My SPA has pages for viewing users and follow / cancel them. We display a counter when you select a user, or expect the result of a subsequent API call.

Is there a best practice when you need to put state related to user interface?

It seems the easiest way to store this in an object entities:

{
  entities: {
    [1]: {
      name: "Bob",
      followed_by_user: true
    },
    [2]: {
      isFetching: true
    }
    [3]: {
      name: "Jane",
      isUpdatingFollowing: true
    }
  }
}

- ? , . state.ui.pages.users , (, USER_CONSTANTS.USER_FOLLOW_SUCCESS: state.ui.pages.users[1].isUpdatingFollowing = false, - state.entities[1].followed_by_user = true, , ).

+4
1

redux , . users - , , , ui, .

, , , , . , () .

: https://github.com/reactjs/redux/issues/601#issuecomment-133519377.

+1

Source: https://habr.com/ru/post/1652475/


All Articles