React update value of textarea like typewriter | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

React update value of textarea like typewriter

I want to update the value of textarea by adding one by one word from given string but it's showing new word and deleting all others. My code where problem exist: https://code.sololearn.com/W8bPOG0yjz0A/?ref=app

17th Oct 2022, 3:28 PM
Bibek Oli
Bibek Oli - avatar
1 Answer
+ 1
When you use function setQuestion you replace the state of question by the value in setQuestion. If you want to display all New question without deleting other : - give an array of string to your usestate, - create an other method onclick that setQuestion with question array and target.value - display the array with Map function into HTML template https://dev.to/shareef/how-to-work-with-arrays-in-reactjs-usestate-4cmi
17th Oct 2022, 4:45 PM
Roland
Roland - avatar