Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!