I\'m replacing an item in a react state array by using the ... spread syntax. This works:
let newImages = [...this.state.images] newImages[4] = updatedImage this
You can use map:
const newImages = this.state.images .map((image, index) => index === 4 ? updatedImage : image)