import React, { useState } from 'react';
import {
IonItem,
IonList,
IonSearchbar,
IonCard,
IonCardHeader,
IonCardTitle,
} from '@ionic/react';
import capsules from '../data/Capsule.json'
function SearchBar() {
let [results, setResults] = useState([...capsules]);
const filterSearch = (ev: Event) => {
let query = "";
const target = ev.target as HTMLIonSearchbarElement;
if (target) query = target.value!.toLowerCase();
setResults(capsules.filter(cap => {
return cap.title.toLowerCase().indexOf(query) > -1;
})
)
}
return (
<>
filterSearch(ev)}>
{ results.map(result => (
{result.title}
))}
>
);
}
export default SearchBar;
/*
<>
{listbio.title}
{listbio.tags}
{listbio.content}
Tomar quiz
>
*/