I have an input where I put X thing, and 5 images appear on top of it. If I put something else in the input, the previous 5 images disappear and 5 images of the requested appear. But now I require that they not disappear, but that they accumulate, in this case the 10 images remain.
From the api query I receive an array with 5 objects where each object has an image.
[{imagen: ...},{imagen: ...},{imagen: ...},{imagen: ...},{imagen: ...},]
And I keep it in a State
const [imagen, setImagen] = useState([])
So that the images are accumulated inside the array, that is, something similar to this happens:
[{imagen: ...},{imagen: ...}, ... x8]
I am dealing with the following ways:
setImagen(...imagen, data)
setImagen(...imagen, [data])
setImagen(...imagen, {data})
setImagen([...imagen, data])
setImagen([...imagen], data)
setImagen([...imagen], {data})
But with none I can save the 5 new images inside the array. How can it be done?
We are not going to steal your code ? the context is very little, but if you want to add more objects to the array, try
If you help me putting more code my answer can improve