Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.
and the source code is
const FilterSearch = () => {
let filter = produtos
if (params.searchType == "CategoriaProduto") {
filter = produtos.filter(categoriaProduto => categoriaProduto.categoria == params.searchContent?.toString())
}
if (params.searchType == "Componente" && params.searchContent?.valueOf != undefined) {
filter = produtos.filter(categoriaProduto => categoriaProduto.nome.includes(params.searchContent ? params.searchContent : ""))
}
return (
filter.map(componente => {
function getLowest() {
if (componente.locaisVendas.length >= 1)
return componente.locaisVendas.reduce((previous, current) => { return current.preco < previous.preco ? current : previous })
else
return null
}
const menorPreco = getLowest()
return (
<tr className="mt-2 my-3" key={componente.id}>
<th className="py-3" >
<img src="/among_us2.png" className="img-fluid" alt="Imagem responsiva" style={{ width: '100px', height: '100px', }} />
 {componente.nome}
</th>
<th className="col-md-2">
<label className="form-check-label fa fa-star text-warning" htmlFor="defaultCheck1"></label>
<label className="form-check-label fa fa-star text-warning" htmlFor="defaultCheck1"></label>
<label className="form-check-label fa fa-star text-warning" htmlFor="defaultCheck1"></label>
<label className="form-check-label fa fa-star text-warning" htmlFor="defaultCheck1"></label>
<label className="form-check-label fa fa-star text-muted" htmlFor="defaultCheck1"></label>
</th>
<th>R$ {menorPreco?.preco}</th>
<th>{menorPreco?.vendedor}</th>
<th>
<Link to={`/Search/Product/${componente.id}`}>
<button className="btn-details rounded p-2"><i className="fa-sharp fa-solid fa-plus mx-1"></i> Ver mais detalhes</button>
</Link>
</th>
</tr>
)
}))
}
I am expecting, to resolve this infinite loop