Question: I am trying to make a function that allows a user to input a number, and add that number to an array. However, if the
I am trying to make a function that allows a user to input a number, and add that number to an array. However, if the user changes their mind, it deletes the previous number that they inputted and inputs a new one. For some reason, the array does not get updated with a new number. If I manually add numbers in the state array, and press the button, it deletes the first number but does not add another one. But if I put in another number in the text input and press the button again, it deletes the first number and adds the previous number I inputted. How can I make it so that it instantly adds the new number while deleting the old one? I did this using react native. Thank you for help in advance. 
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
