0
I have the following state in hook on Reactjs:
const[faixas, setFaixas] = useState([
{albumId: 1, nome: "nome da musica"},
{albumId: 1, nome: "nome da musica"},
{albumId: 2, nome: "nome da musica"}
])
const[albuns, setAlbuns] = useState([
{id: 1, nome: "nome do album"},
{id: 2, nome: "nome do album"}
])
So what I’m trying to do is, I have an array of tracks that will tell me what album she’s on by albumId. I therefore need that in the state album i have an array of tracks, so the albuns state would look like this :
albuns([{id: 1, nome: "nome do album",
faixas: {
{albumId: 1, nome: "nome da musica"},
{albumId: 1, nome: "nome da musica"}
},
{id: 2, nome: "nome do album",
faixas: {
{albumId: 2, nome: "nome da musica"}
}]
)
how can I do this? I couldn’t do it using useState changes:
setAlbuns((prev:any) => {
return [...albuns, faixas.albumId]
})
I don’t know how I could do that,