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

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

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 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!