Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
Optimal way to refetch data when URL parameters change?

I have stumbled upon this problem a few times now. I need a way for the component to be able to track changes in the URL params and refetch data depending on it. For example, when the user searches "q=searchTerm" is applied. When paginating, "page=pageNumber" is applied and so on. It is easy to implement with just one parameter in a useEffect but when I have multiple such as search, sort, sort direction my knowledge of this is limited.

The code right now sort of works but if you are on say page 3 in pagination and then you search both effects get triggered because I want the pagination to go back to 1 after searching. It is not ideal.

I can't really find any good articles which deal with a more advanced version as they usually just demo the concept.

Can anyone recommend a good approach of dealing with multiple search parameters and how to efficiently update data?

    fetchMore({
      variables: {
        input: {
          offset: getOffset(MAX_PRODUCT_REVIEW_LIMIT, activePage),
          limit: MAX_PRODUCT_REVIEW_LIMIT,
          q: debouncedSearchTerm,
        },
      },
    });
  }, [activePage, fetchMore, debouncedSearchTerm]);

  useEffect(() => {
    Router.replace({
      query: {
        ...Router.query,
        q: debouncedSearchTerm,
        page: 1,
      },
    });
  }, [debouncedSearchTerm]);
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda