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