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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started