title: How to set focus or cursor on TextInput in react native
body: <p>I am using <code>TextInput</code> component of react native. I want to set focus on it inside onPress function.</p>
  
  <pre><code>&lt;TextInput
    ref="messageTextInput"
    style={{
      height: 40,
      width: "100%",
      borderColor: "gray",
      borderWidth: 1,
      marginTop: 8
    }}
    underlineColorAndroid="transparent"
    placeholder={strings.enter_your_message}
    onChangeText={text =&gt; this.setState({ text })}
  /&gt;
  
  _onPress(navigate) {
    try {
      if (!this.state.text.trim()) {
        Alert.alert(strings.app_name, strings.validate_text);
        this.messageTextInput.focus();
      }
    } catch (error) {
      console.log(error);
    }
  }
  </code></pre>
  
  <p>It doesn't set focus or cursor on messageTextInput. Does anyone know how to do this in react native ?</p>