+ 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
1 Resposta
+ 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