title: connect react redux HOC got error of `Cannot call a class as a function`
body: <p>What's wrong with my HOC below? I got error of cannot call a class as function?</p>
  
  <p><a href="https://i.imgur.com/SirwcGZ.png" rel="nofollow noreferrer">https://i.imgur.com/SirwcGZ.png</a></p>
  
  <p>My HOC</p>
  
  <pre><code>const CheckPermission = (Component) =&gt; { 
      return class App extends Component { 
          componentDidMount() {
              this.props.fetchUsers().then(resp =&gt; {
                  this.setState({user: true, loading: false});
              })
          } 
          render() { 
             const { user, loading } = this.props
  
             loading &amp;&amp; &lt;div&gt;Loading...&lt;/div&gt;
  
             !user &amp;&amp; &lt;Redirect to="/dashboard" /&gt;
  
             return &lt;Component {...this.props} /&gt;
          }
      } 
  }
  
  
  export default connect(state=&gt;state.global, {fetchUsers})(CheckPermission)
  </code></pre>
  
  <p>This is how I import and user CheckPermission:</p>
  
  <p><code>&lt;Route exact path='/dashboard' component={CheckPermission(Dashboard)} /&gt;</code></p>