const userIds = _.uniq(_.map(getState().posts, 'userId')); userIds.forEach((id) => dispatch(fetchUser(id)));
can be refactored with lodash _.chain function into:
_.chain(getState().posts) .map('userId') .uniq() .forEach(id => dispatch(fetchUser(id))) .value();