I have arrays of colors, with each color I have a gallery. I want to create and manage state for these galleries, so I can add/remove image for gallery easy.
I have code like this
var imgArr = new Array(colors.length)
for (var i = 0; i < colors.length; i++) {
imgArr[i] = colors[i].imgs
const [gallery[i], setGallery[i]] = React.useState()
setGallery[i](imgArr[i])
}
but const [gallery[i], setGallery[i]] = React.useState() doesn't work.
How to resolve this issue?