title: ReactJS: Cannot get the length of a string in component state
body: <p>I have a little problem. In my function <code>isLoginOk()</code> it never enters into the <code>if</code>. It enters every time in the <code>else</code> even if my string is longer than 1 char.</p>
  
  <p>When I <code>console.log</code> before the <code>if</code> I can see that my string is longer than 1 yet it doesn't go into the <code>if</code>! </p>
  
  <p>Why is that? (I have verified that the string in my component state is correctly updated by <code>handleChange()</code>)</p>
  
  <pre><code>export default class InputLogin extends React.Component {
          constructor(props) {
              super(props);
          this.state = {
              login: "",
          }
      };
  
      handleChange = (e) =&gt; {
          this.setState({
              [e.target.name]: [e.target.value]
          });
      }
  
      isLoginOk() {
          if (this.state.login.length &gt; 1) {
              return (&lt;div&gt;OK&lt;/div&gt;);
          } else {
              return (&lt;div&gt;ERROR&lt;/div&gt;);
          }
      }
  
      render() {
          return (
              &lt;div&gt;
                  &lt;input type="text" name="login" value={this.state.login} onChange={this.handleChange} /&gt; {this.isLoginOk()}
              &lt;/div&gt;
          );
      }
  }
  </code></pre>