With this:
setImages({ images });
you are setting the images
variable to be an object which has one property, images
, which is an array, kind of like this:
const imagesForNextRender = {
images: [
/* image data */
]
};
But you can't .map
that. Either extract the images
property first (not recommended):
images.images.map(
or, more sensibly, call setImages
with the array itself, rather than wrapping it in an object:
const result = await axios("https://jsonplaceholder.typicode.com/photos");
setImages(result.data);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…