title: onChangeText returns the previous state value
body: <p>I am trying to make a dynamic form. The user must enter the required <strong>count</strong> of fields in the first text field. After that, I add the entered <strong>count</strong> to the state and render all the fields. But in "onChangeText" the <strong>previous state</strong> value is returned. At the same time, if I click on the button, the <strong>current state</strong> value is returned?</p>
  
  <pre><code>import React, {useState} from "react";
  import {Button, TextInput, View, StyleSheet} from "react-native";
  
  export const TestScreen = () =&gt; {
      const initialState: any = {
          num: null,
          inputs: null
      };
      const [state, setState] = useState(initialState);
  
      const changeNum = (num = null) =&gt; {
          const inputs = [];
          if (num) {
              for (let i = 0; i &lt; num; i++) {
                  inputs.push(
                      &lt;TextInput
                          key={i.toString()}
                          style={styles.input}
                          onChangeText={changeNewInput}
                      /&gt;
                  )
              }
          }
          setState({num, inputs})
      };
  
      const changeNewInput = (e) =&gt; {
          console.log(state.num)
      };
  
      return (
          &lt;View&gt;
              &lt;TextInput onChangeText={changeNum} style={{...styles.input, borderColor: 'red'}}/&gt;
              {state.inputs}
              &lt;Button title={'see count'} onPress={() =&gt; console.log(state.num)}/&gt;
          &lt;/View&gt;
      )
  };
  
  const styles = StyleSheet.create({
      input: {
          borderWidth: 1,
          borderColor: 'black',
          marginBottom: 5
      }
  });
  </code></pre>