I am having an array stored in a state. When I try to push new data to array, it is returning this error:
Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.
This is the code I am using:
const [currencies,setCurrencies] = useState(['USD', 'AUD', 'SGD', 'PHP', 'EURP']);
setCurrencies(currencies => [...currencies, 'NSD', 'PLN']);