Version 2.24.70 Breaks How location.search Gets Updated
See original GitHub issueDescription
Starting with version 2.24.70 my website’s search field stopped working.
Steps to reproduce
- Checkout the minimal reproduction
- Run
yarn install && yarn run develop
- Open
http://localhost:8000/
in the browser and try the search field. Note that it does work. - Change “<2.24.70” in package.json to “^2.24.70”
- Run
yarn install && yarn run develop
- 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:
- Created 3 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks again! Published in
gatsby@2.24.85
@vladar @WillMayger It works like a charm. Thank you very much.