title: Error with HOC in Role Based Authorization in React
body: <p>I have been trying implement to <a href="https://medium.com/better-programming/role-based-authorization-in-react-c70bb7641db4" rel="nofollow noreferrer">Role Based Authorization in React</a> as below</p>
  
  <p>In authorization.js, it is checked if the logged-in user with his role, is allowed to access the page or not:</p>
  
  <pre><code>import React from "react";
  
  const Authorization = (WrappedComponent, allowedRoles) =&gt; {
    return class WithAuthorization extends React.Component {
      constructor(props) {
        super(props);
  
        this.state = {
          user: {
            name: "vcarl",        
            role: "Admin"
          }
        };
      }
      render() {
        const { role } = this.state.user;
        if (allowedRoles.includes(role)) {
          return &lt;WrappedComponent {...this.props} /&gt;;
        } else {
          return &lt;h1&gt;No page for you!&lt;/h1&gt;;
        }
      }
    };
  };
  
  export default Authorization;
  </code></pre>
  
  <p>In App.js</p>
  
  <pre><code>render() {
      const accounts = Authorization(["SuperAdmin", "Admin"]);
  
      return (
        &lt;StateContext.Provider value={{ ...this.state }}&gt;
          &lt;Router&gt;                   
              &lt;Route
                exact
                path="/accounts"
                component={accounts(Accounts)}
              /&gt;         
          &lt;/Router&gt;
        &lt;/StateContext.Provider&gt;
      );
    }
  </code></pre>
  
  <p>In Accounts.js:</p>
  
  <pre><code>import React, { Component } from "react";
  
  class Accounts extends Component {
    render() {
      return &lt;div&gt;Accounts page&lt;/div&gt;;
    }
  }
  
  export default Accounts;
  </code></pre>
  
  <p>But get the error:</p>
  
  <pre><code>TypeError: Class constructor WithAuthorization cannot be invoked without 'new'
  </code></pre>
  
  <p>Any suggestions?</p>