Redux选择器(过滤器)导致重新渲染-如果其他状态发生了变化

My component (showing redux state.assets) will rerender when I update an other redux state (for example state.comments - both are in the same store).

仅当我过滤状态时才会发生

const filterAssetsTest = assets => {
    //return assets; <------------------------------------------------ no problem, but doesn't filter

    return assets.filter(asset => {
        return asset.project_id === '123';
    });
};

const mapStateToProps = (state, ownProps) => {
    return {
        assets: filterAssetsTest(state.assets),
        //assets: state.assets, // <---------------------------------- no problem, but doesn't filter
    };
};

如何解决呢?

评论