title: Console.log not working my react app browser
body: <p>I am trying to test whether my 'login' button works and console.log displays the credentials entered into the username and password fields. Myreact app starts up fine and renders the username and password fields for the user to enter their credentials. Its just the consol.log that seems to be the problem :/</p>
  <h1>I have the following code within my login.js file below for console log:</h1>
  <pre><code>state = {
      credentials: {username: '', password: ''}
  }
  Login = event =&gt; {
      console.log('this.state.credentials');
  }
  </code></pre>
  <h1>My login.js file</h1>
  <pre><code>import React, { Component} from 'react';
  
  // Class components need a render function
  class Login extends Component {
  
      state = {
          credentials: {username: '', password: ''}
      }
      Login = event =&gt; {
          console.log('this.state.credentials');
      }
  
      inputChanged = event =&gt; {
          const cred = this.state.credentials;
          cred[event.target.name] = event.target.value;
          this.setState({credentials: cred});
        }
      
        render() {
          return (
            &lt;div&gt;
              &lt;h1&gt;Login user form&lt;/h1&gt;
              &lt;label&gt;
                Username:
                &lt;input type=&quot;text&quot; name=&quot;username&quot;
                 value={this.state.credentials.username}
                 onChange={this.inputChanged}/&gt;
              &lt;/label&gt;
              &lt;br/&gt;
              &lt;label&gt;
                Password:
                &lt;input type=&quot;password&quot; name=&quot;password&quot;
                 value={this.state.credentials.password}
                 onChange={this.inputChanged} /&gt;
              &lt;/label&gt;
              &lt;br/&gt;
              &lt;button onClick={this.login}&gt;Login&lt;/button&gt;
              &lt;button onClick={this.register}&gt;Register&lt;/button&gt;
            &lt;/div&gt;
          );
        }
      }
      
      export default Login;
  </code></pre>
  <h1>My App.js file</h1>
  <pre><code>import React from 'react';
  import './App.css';
  import Login from './components/login';
  
  function App() {
    return (
      &lt;div className=&quot;App&quot;&gt;
        &lt;Login /&gt;
      &lt;/div&gt;
    );
  }
  
  export default App;
  </code></pre>
  <h1>My Index.js file</h1>
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import './index.css';
  import App from './App';
  import reportWebVitals from './reportWebVitals';
  
  ReactDOM.render(
    &lt;React.StrictMode&gt;
      &lt;App /&gt;
    &lt;/React.StrictMode&gt;,
    document.getElementById('root')
  );
  
  // If you want to start measuring performance in your app, pass a function
  // to log results (for example: reportWebVitals(console.log))
  // or send to an analytics endpoint. Learn more: xyz;
  </code></pre>
  <p>Any help is appreciated!</p>