title: How to change TextInput cursor position in React Native?
body: <p>I am trying to achieve this behaviour in React Native: The user type for example 5 then ".000" will be added automatically to the <code>TextInput</code> , but the user can add an other number for example 7, the final result should look like "57.000".</p>
  
  <p>I tried to find a workaround but calculating the length of value and add chars accordingly but it didn't work as expected.</p>
  
  <p>Then I found the <code>selection</code> props of the <code>TextInput</code>.</p>
  
  <p>Here is my take on this:</p>
  
  <p>I added this to state</p>
  
  <pre><code>selection: {
    start: 0,
    end: 0
  }
  </code></pre>
  
  <p>Here is my <code>TextInput</code></p>
  
  <pre><code>&lt;TextInput
          onFocus={setSelection}
          selection={selection}
          keyboardType="numeric"
          onChangeText={(text) =&gt; onChangeText("val", text)}
          value={val}
          editable={true}
          selectTextOnFocus={false}
   /&gt;
  </code></pre>
  
  <p>Here is onChangeText method</p>
  
  <pre><code>onChangeText = async (key, value) =&gt; {
    var numDots = value;
    if (value.indexOf(".000") === -1) {
      numDots = value + ".000"
    }
    this.setState({ [key]: numDots });
  };
  </code></pre>
  
  <p>And here is the setSelection method</p>
  
  <pre><code>setSelection = () =&gt; {
     this.setState({ select: { start: 1, end: 1 } });
  };
  </code></pre>
  
  <p>The problem is whenever I type, the cursor is always focusing on index <code>0</code>, I think <code>setSelection</code> is not being triggered. </p>
  
  <p>Is there something I'm doing wrong? </p>
  
  <p>I hope someone would help me in this. Thanx in advance.</p>