As Salehen Rahman mentioned above in the comments that I made using react-redux .
Following their documentation, I created two functions: one to display the "global state" in the component details:
function mapStateToProps(state) { return { users: state.users.items }; }
and one for matching sent actions with functions transferred to the component as a requisite:
function mapDispatchToProps(dispatch) { return { lockUser: (id) => dispatch(actions.lockUser(id)), unlockUser: (id) => dispatch(actions.unlockUser(id)), updateUser: (id, user) => dispatch(actions.updateUser(id, user)), addUser: (user) => dispatch(actions.addUser(user)) }; }
Then everything comes together using the connect method:
export default connect(mapStateToProps, mapDispatchToProps)(UsersContainer);
I have a feeling that all this under the hood applies the unsubscribe method to the component, but this greatly simplifies the situation.
source share