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

107
Visualizações
Displaying the data issue on search and filtering in react

I have created dummy users data and displayed it in the table format.

It contains search and filtering of the data(should consider the entire data set not based on the current page data).

Disabled pagination on displaying the filtering/search results. Here search, filtering function works fine on the 1st page. But when I tried to do a search/ filter on the second page, it displays no data found instead of the filtered results.

When I log the search/filter function results, it displays the proper result in the console, but it is not displaying in the table.

I'm not able to fix the issue. Here is the link to codesandbox.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your data flow is not correct. Let's review it together:

The pagination working properly, the getPaginatedData will get the proper data to show on your table. so far so good, but when you change the page pagination, the getPaginatedData will not be saved anywhere. this handler only returns the data on the table and there isn't any user to search in their name.

To solve the issue, I recommend using another state variable with another useEffect hook to control the page pagination and data (lead to get proper data on search).

You need to implement something like this:

// rest of the codes ...

const [currentPage, setCurrentPage] = useState(1);

const [tableData, setTableData] = useState([]);

useEffect(() => {
    const startIndex = currentPage * dataLimit - dataLimit;
    const endIndex = startIndex + dataLimit;
    const result =  users.slice(startIndex, endIndex);
    
    setTableData(result))

}, [currentPage])

// rest of the codes ...

Now with every change with the page number (pagination), this useEffect hook will trigger and set the proper data to show on the table, then you can use the tableData on your search filter instead of the user data.

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