title: calling redux connect on a decorator?
body: <p>I am trying to call <code>connect</code> on a decorator that returns a react class</p>
  
  <pre><code>const SetLanguageFromPage = () =&gt; {
    return WrappedComponent =&gt;
      class setLang extends React.Component {
        static propTypes = {
          pathContext: PropTypes.shape({
            language: PropTypes.string.isRequired
          })
        };
  
        componentDidMount() {
          const currentLanguage = i18n.language;
          const pageLanguage = this.props.pathContext.language;
  
          // First request
          if (!currentLanguage) {
            i18n.language = pageLanguage;
          }
  
          // Only update on language change
          if (currentLanguage !== pageLanguage) {
            i18n.changeLanguage(pageLanguage);
          }
        }
  
        render() {
          return &lt;WrappedComponent {...this.props} /&gt;;
        }
      };
  };
  
  const mapStateToProps = (state) =&gt; { return{...} }
  const mapDispatchToProps = (dis) =&gt; { return{...} }
  
  export default connect(...)(SetLanguageFromPage);
  </code></pre>
  
  <p>but when I then use the decorator on another react class I get this error...</p>
  
  <pre><code>Uncaught TypeError: Cannot call a class as a function
  </code></pre>
  
  <p>which I suppose is from <code>connect</code> changing my function to a react class. Is there any way to accomplish what I am trying to do? I would really like to be able to call actions to set the state from within this decorator, but I can't see how I can get at the <code>store</code> to call <code>dispatch</code> or map the dispatch to the props...</p>
  
  <p>I am using <a href="https://www.gatsbyjs.org/" rel="nofollow noreferrer">https://www.gatsbyjs.org/</a> for this, so the general method has the store instantiated in a way where I cannot access is directly</p>