title: How do I avoid re-rendering a connected React PureComponent due to mapDispatchToProps functions?
body: <p>whenever mapDispatchToProps is called, it generates new functions to return. For example:</p>
  
  <pre><code>const mapDispatchToProps = function(dispatch, ownProps) {
    return {
      addToStack: (episodeId, stackId) =&gt; {
        return dispatch(StackAction.addEpisodeToStack(episodeId, stackId));
      },
    };
  }
  </code></pre>
  
  <p>Every time the mapDispatchToProps is called, it will generate a new object, with a new arrow function. </p>
  
  <p>In my application I often have to avoid re-rendering my components. Using a PureComponent is often the way to go. However, since the functions are always different, PureComponent won't help and I'd have to create a shouldComponentUpdate strategy. There, I'd have to "blacklist" all of the mapDispatchToProps functions and ignore all of them. I'd have to add every new function to the list so it'd avoid re-rendering.</p>
  
  <p>here is an example of the blacklist shouldComponentUpdate boilerplate:</p>
  
  <pre><code>const blacklist = [
    'addToStack',
  ]
  
  shouldComponentUpdate(nextProps, nextState) {
    for (let i in nextProps) {
      if (blacklist.includes(i)) continue;
      if (nextProps[i] !== this.props[i]) {
        return true;
      }
    }
    for (let i in nextState) {
      if (nextState[i] !== this.state[i]) {
        return true;
      }
    }
    return false;
  }
  </code></pre>
  
  <p>I've come up with a new solution</p>
  
  <pre><code>const dispatch;
  const mapDispatchToPropsFunctions = {
    addToStack: (episodeId, stackId) =&gt; {
      return dispatch(StackAction.addEpisodeToStack(episodeId, stackId));
    },
  };
  
  const mapDispatchToProps = function(dispatchArg, ownProps) {
    dispatch = dispatchArg
    return mapDispatchToPropsFunctions;
  }
  </code></pre>
  
  <p>this way the functions are constant and won't trigger a re-rendering of a PureComponent and I don't have to maintain a shouldComponentUpdate function.</p>
  
  <p>however this seems wrong to me.
  Is there a "default" way of dealing with this problem?</p>