我重新选择了每次在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);