I have a table of users and I have to filter/search users by the name entered. For example, when typing John, I must list all users named John in the table.
Table code with all users
ListPatients.js
const ListPatients = ({ pacientes, setPacientes }) => {
const removePaciente = (idToDelete) => {
const newTasks = [...pacientes];
newTasks.splice(idToDelete, 1);
setPacientes(newTasks);
};
return (
<div style={{ display:"flex", alignItems:"center", flexDirection:'column'}}>
<h1>List</h1>
<Table style={{ border:'1'}}>
<thead>
<tr style={{padding:'0 1rem'}}>
<th>Name</th>
<th>Birth date</th>
<th>CPF</th>
<th>Gender</th>
<th>Addres</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{pacientes.length > 0 ? (
pacientes.map((paciente, index) => (
<tr key={paciente.id}>
<td>{paciente.name}</td>
<td>{paciente.birth date}</td>
<td>{paciente.cpf}</td>
<td>{paciente.gender}</td>
<td>{paciente.address}</td>
<td>{paciente.status}</td>
<td>
<Button className="button muted-button" onClick={() => removePaciente(index)}>
<i style={{ color: "red" }} className="fa-solid fa-trash fa-xl"></i>
</Button>
<Button className="button muted-button">
<i style={{ color: "orange" }} className="fa-solid fa-pen-to-square fa-xl"></i>
</Button>
{/* {condition === true ? <Cadastrar /> : <ListarPacientes />} */}
</td>
</tr>
))
) : (
<tr>
<td colSpan={3}>Sem pacientes</td>
</tr>
)}
</tbody>
</Table>
</div>
)
}
export default ListPatients
Note: I'm using localStorage to store the data.

How do I do it using a search input? Help please.
