title: TypeError: undefined is not an object (evaluating 'this.setState')
body: <p>I keep getting this error, and I don't know why, because everything I have tried don't work. Does anybody knows why this is not working and how it can work?</p>
  
  <p>I get this undefined here:</p>
  
  <pre><code>this.setState({isAuthenticated: true})
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>class Login extends Component{
  
          constructor(props){
              super(props);
  
              this.state ={
                  email: '',
                  password: '',
                  isAuthenticated: false
              };
  
              function login(username, email){
                  sessionStorage.setItem('loginSessionUsername', username);
                  sessionStorage.setItem('loginSessionEmail', email);
                  this.setState({isAuthenticated: true})
              }
          }
  
          render(){
              const isAuthenticated = this.state.isAuthenticated;
              if(isAuthenticated){
                  return(
                      &lt;div&gt;
                          &lt;Servicedesk /&gt;     
                      &lt;/div&gt;
                  )
              }
              return(
                  &lt;div id='Login' className='setVisible'&gt;
                      &lt;div&gt;
                          &lt;label&gt;Emailadres&lt;/label&gt;
                          &lt;input type='text' placeholder='je email' onChange={ev =&gt; this.setState({email: ev.target.value})}/&gt;
                          &lt;label&gt;Wachtwoord&lt;/label&gt;
                          &lt;input type='password' placeholder='je wachtwoord' onChange={ev =&gt; this.setState({password: ev.target.value})}/&gt;
                          &lt;br /&gt;
                          &lt;button onClick={(event =&gt; this.handleClick(event))}&gt;Submit&lt;/button&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              )
          }
      }
  
      export default Login;
  </code></pre>