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
Global search input on React page

I have a search input in my <Layout> component. The UX I would like is that when you start typing in the box, it changes the URL to /search/?=whatever and uses the Search page to render my results. I have this mostly working but there is a persistent problem where a few characters will go missing, usually the 3rd or 4th, as things transition from the original page to the search page. The code is all up on https://github.com/coderanger/buddy.farm/ if that helps. Might be more of a generic React question but the heart of the issue seems to be navigate() forcing my input focus away from the text field while things process or something?

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

0

So I ended up solving this with three rounds of changes. First was the effect fixes mentioned by Andrew Gillis above, those were just straight up bugs. Second was to move the search index out of Gatsby page data (it was previously a static query in the page) and into its own JSON file. Shoutout to this blog post for laying out exactly how, but the short version is to use a createPages hook to run the same GraphQL query and write it to public/search.json, and then write some normal React stuff to load that data when the page mounts with a loading spinner and whatnot. And then third, I used a global context to continue recording the user inputs via onChange event after a navigate() was started and then restore from that once the page mounts.

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