How to limit react-redux connect update re-renders to specific state branches?

后端 未结 3 1171
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 18:06

I have an action and reducer that updates a global counter. This action is fired on a rapid interval. The reducer returns a new copy of the state for each action. The reduce

3条回答
  •  爱一瞬间的悲伤
    2020-12-10 18:58

    Redux connect accepts a areStatesEqual function option that can be used to narrow down equality checks to specific state branches.

    export default connect(
      {},
      {},
      null,
      {
        areStatesEqual: (next, prev) => {
          return (
            prev.branch === next.branch
          );
        }
      }
    )(Component);
    

提交回复
热议问题