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

151
Views
how to do custom global filtering on the react table

for eg. I have covid data and I display it in the react table it contains the columns like continent, country, new cases, total cases, active cases, deaths etc. now I want to do filtering on the table where it returns row if I enter county or continent name if I enter any other key in input field it should not return anything in the table just show result not found.

global filter function:

function GlobalFilter({filter, setFilter}) {
    const[value, setValue] = useState(filter);

    const onChange = useAsyncDebounce((value)=>{
        setFilter(value || undefined);
    }, 1000);

    return (
        <div className='filter'>
            <input value={filter || ''} onChange={(e)=>{
                setFilter(e.target.value) 
                onChange(e.target.value)}} placeholder='Enter Country or Continent'/>
        </div>
    

column of the table:

 COLUMNS = [
    {
        Header : 'Continent',
        accessor : 'continent',
    },
    {
        Header : 'Country',
        accessor : 'country',
    },
    {
        Header : 'Total Cases',
        accessor : 'totalcases',
    },
    {
        Header : 'Active Cases',
        accessor : 'activecases',
    },
    {
        Header : 'Total Recovery',
        accessor : 'recovery',
    },
    {
        Header : 'Total Death',
        accessor : 'deaths',
    },
    {
        Header : 'New Cases',
        accessor : 'newcases',
    },
    

]

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is how I usually do this:

const CovidData = () => {
 const [data, setData] = useState([//your data goes here])
 const [filter, setFilter] = useState(null) //null = show all items

 const filteredItems = filter ? data.filter(elem => elem.country === filter) : data

 return (
  <>
    <input onChange={e => setFilter(e.target.value)} />
    <TableComp items={filteredItems} />
  </>
 )
}

This is untested, but you should get the gist :)

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!