使用仅在denormalize中的输入数据中提到的实体

时间:2017-09-02 15:35:37

标签: javascript redux reselect normalizr

我重新选择了每次在redux存储中的任何集合被更改时重新呈现的选择器,但是我希望它只在输入数据中引用的ID被更改时才更改。这是否可以使用当前的denormalize函数?

代码是:

// TODO: fix rerenders
const mediaSelector = createSelector(
  ({ media }) => media.byId,
  ({ documents }) => documents.byId,
  ({ photos }) => photos.byId,
  ({ photoSizes }) => photoSizes.byId,
  ({ files }) => files.locations.byId,
  (_, { media }) => media,
  (media, documents, photos, photoSizes, fileLocations, data) => {
    console.count('Connected Media');
    return denormalize(data, schema, {
      media,
      documents,
      photos,
      photoSizes,
      fileLocations,
    });
  },
);
const mapState = createStructuredSelector({
   media: mediaSelector,
});
const enhance = connect(mapState);

1 个答案:

答案 0 :(得分:0)

好的,我用我的npm包解决了它 normalizr-entities

这就像用于normalizr非规范化的镜头