Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

120
Visualizações
React - TypeScript - Uncaught TypeError: setSearchQuery is not a function

I am getting this error: Uncaught TypeError: setSearchQuery is not a function in Next.js / Typescript app where I am typing a search query inside search box. I created a generic search function in TypeScript and all my code works well expect I am getting this tiny error... Any ideas what I am doing wrong?

TopPanel.tsx

  export interface ISearchInputProps {
  setSearchQuery: (searchQuery: string) => void; 

  export const TopPanel = (props: ISearchInputProps) => {
    const { setSearchQuery } = props;
    return (
        <div>
            <input
              type="text"
              placeholder="Search Assets..."
              onChange={(event) => 
                setSearchQuery(event.target.value)}
            />
          </div>
        );
       }

AssetsList.tsx

 import generiSearch from 'src/utils/genericSearch' 

 const [query] = useState<string>('');````

 const filteredData = reserves
    .filter((res) => genericSearch(res, ['symbol'], query, false))
    .map((reserve) => ({
      ...rest of the code...
    }));

    return (
     ... 
   );
  }

genericSearch.ts

export default function genericSearch<T>(
  object: T,
  properties: Array<keyof T>,
  query: string,
  shouldBeCaseSensitive: boolean
): boolean {
  if (query === '') {
    return true;
  }

  const expression = properties.map((property) => {
    const value = object[property];

    if (typeof value === 'string' || typeof value === 'number') {
      if (shouldBeCaseSensitive) {
        return value.toString().includes(query);
      } else {
        return value.toString().toLowerCase().includes(query.toLowerCase());
      }
    }

    return false;
  });
  return expression.some((expression) => expression);
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I am thinking, the problem is that you call setSearchQuery in TopPanel without props definition. ISearchInputProps is only interface.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda