question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Version 2.24.70 Breaks How location.search Gets Updated

See original GitHub issue

Description

Starting with version 2.24.70 my website’s search field stopped working.

Steps to reproduce

  1. Checkout the minimal reproduction
  2. Run yarn install && yarn run develop
  3. Open http://localhost:8000/ in the browser and try the search field. Note that it does work.
  4. Change “<2.24.70” in package.json to “^2.24.70”
  5. Run yarn install && yarn run develop
  6. Open http://localhost:8000/ in the browser and try the search field. Note that it does not work.

It looks like since 2.24.70 the changes to location.search don’t cause the useEffect hook to execute.

  useEffect(() => {
    const newSearchQuery = new URLSearchParams(location.search).get(`q`) || ``
    setSearchQuery(newSearchQuery)
    if (newSearchQuery) {
      updateResults(newSearchQuery)
    }
  }, [location.search])

Expected result

The useEffect hook should run. The website should display the search results.

Actual result

It doesn’t.

Environment

  System:
    OS: macOS 10.15.6
    CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
    Shell: 5.0.18 - /usr/local/bin/bash
  Binaries:
    Node: 14.8.0 - ~/.nvm/versions/node/v14.8.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.7 - ~/.nvm/versions/node/v14.8.0/bin/npm
  Languages:
    Python: 2.7.17 - /Users/asd/.pyenv/shims/python
  Browsers:
    Chrome: 86.0.4240.75
    Firefox: 81.0.1
    Safari: 14.0
  npmPackages:
    gatsby: ^2.24.70 => 2.24.72 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
vladarcommented, Oct 22, 2020

Thanks again! Published in gatsby@2.24.85

1reaction
adonigcommented, Oct 22, 2020

@vladar @WillMayger It works like a charm. Thank you very much.

Read more comments on GitHub >

github_iconTop Results From Across the Web

location.search - Web APIs | MDN
The search property of the Location interface is a search string, also called a query string; that is, a string containing a '?...
Read more >
gatsby/CHANGELOG.md at master - GitHub
The fastest frontend for the headless web. Build modern websites with React. - gatsby/CHANGELOG.md at master · gatsbyjs/gatsby.
Read more >
How can I get a specific parameter from location.search?
My favorite way for getting URL params is this approach: var parseQueryString = function() ...
Read more >
gatsby | Yarn - Package Manager
Get started with Gatsby locally in 5 Minutes. You can get a new Gatsby site up and running on your local dev environment...
Read more >
Roy Choi - Wikipedia
Roy Choi (born February 24, 1970) is a Korean-American chef who gained prominence as the creator of the gourmet Korean-Mexican taco truck Kogi....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found