gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.28k stars 10.31k forks source link

onRouteUpdate not firing #26849

Closed frodehansen2 closed 4 years ago

frodehansen2 commented 4 years ago

Description

onRouteUpdate function in gatsby-browser fires only one time after page is loaded, afterwards it never gets called. The bug can be seen here: https://www.nav.no/familie/sykdom-i-familien/nb/pleiepenger-for-sykt-barn

Steps to reproduce

Build site and click on anchor links - the function is called on the first anchor click, but not on the second.

Expected result

onRouteUpdate should be called

Actual result

onRouteUpdate was not called

Environment

System: OS: macOS 10.15.6 CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.17.0 - /usr/local/bin/node Yarn: 1.19.1 - /usr/local/bin/yarn npm: 6.14.8 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/bin/python Browsers: Chrome: 85.0.4183.83 Firefox: 80.0.1 Safari: 13.1.2 npmPackages: gatsby: ^2.24.56 => 2.24.56 gatsby-image: ^2.4.17 => 2.4.17 gatsby-plugin-compile-es6-packages: ^2.1.0 => 2.1.0 gatsby-plugin-intl: 0.2.8 => 0.2.8 gatsby-plugin-less: ^3.2.9 => 3.2.9 gatsby-plugin-react-helmet: ^3.3.10 => 3.3.10 gatsby-plugin-react-svg: ^2.1.2 => 2.1.2 gatsby-plugin-routes: ^1.0.0 => 1.0.0 gatsby-plugin-tslint: 0.0.2 => 0.0.2 gatsby-plugin-typescript: ^2.4.19 => 2.4.19 gatsby-source-sanity: ^5.0.6 => 5.0.6 npmGlobalPackages: gatsby-cli: 2.12.93 gatsby: 2.15.18

frodehansen2 commented 4 years ago

Replaced it export const shouldUpdateScroll = (props) => { return !props.routerProps.location.hash; };