0

I am new Comer to react native. I need to, How to push setState array to new data?

enter image description here

https://i.stack.imgur.com/uvtr4.png

ANJANA
  • 27
  • 1
  • 8

1 Answers1

0

setCurrencies(prevCurrencies => [...prevCurrencies, 'UAH', 'PLN'])

More info here https://stackoverflow.com/a/54677026/10617148

Vasyl Nahuliak
  • 1,912
  • 2
  • 14
  • 32
  • ERROR Error: Too many re-renders. React limits the number of renders to prevent an infinite loop. I have this error – ANJANA May 29 '21 at 19:46
  • I guess you put this code in "render" scope (it's meaning code before return in component). Please create handler function and pass into Button component as example: in render `const handlePress = () => { setCurrencies(prevCurrencies => [...prevCurrencies, 'UAH', 'PLN']) }`, after return `` Also you can see more example in here https://reactnative.dev/docs/button – Vasyl Nahuliak May 30 '21 at 16:45