Intentando mostrar los resultados después de aplicar la función de filtro. Necesito comparar con searchValue. Pero da error
{noteList.filter((obj,index) => <Card
noteObj={obj.Name.toLowerCase().includes(searchValue)}
index={index}
deleteNote={deleteNote}
updateNoteArray={updateNoteArray}
/>)
}
Primero debe filtrar las opciones de la matriz noteList de acuerdo con su condición y luego aplicar un map sobre ella.
{
noteList.filter((obj) => obj.Name.toLowerCase().includes(searchValue))
.map((item,index) => <Card
noteObj={item}
index={index}
deleteNote={deleteNote}
updateNoteArray={updateNoteArray}
/>
)
}
noteList.filter((obj)=>obj.Name.toLowerCase().includes(searchValue))
Esto devolverá una nueva matriz que contiene todos los nombres que incluirán searchValue . Luego puede usar esta matriz resultante para mostrar su resultado
usar map no filter
{ noteList
.filter((obj, index)=>{ return obj.Name.toLowerCase().includes(searchValue)})
.map((obj,index) => <Card
noteObj={obj}
index={index}
deleteNote={deleteNote}
updateNoteArray={updateNoteArray}
/>)
}