My issue is that when i call the function getAllFlashCardsFromQuest(), its call all flash cards ever created in all the pages, i wanna only the objects that comes from a specific pathname, or a way to filter the cards array.
async function getCards() {
let cardsValues = await getAllFlashCardsFromQuest() as FlashCard[]
let cardsFiltered = cardsValues.filter(()=>{
return history.location.pathname === 'CriarAlternativaQuest'
})
console.log(cardsFiltered)
setCards(cardsFiltered)
}
There's not much context with your code, so I can only help so much, but one thing's for sure, and that is
history.location.pathname
isn't changing and you're comparing it with another constant. SocardsFiltered
will be either a list of true or a list of false.Whenever you're filtering a list, you need to take each item or a property of each item and use that in your comparison.
Ex.
The thing is that you need to figure out what value or property inside of your
cardsValues
list that you need to compare it with 'CriarAlternativaQuest'