1
0

gatsby-browser.js 958 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * Implement Gatsby's Browser APIs in this file.
  3. *
  4. * See: https://www.gatsbyjs.org/docs/browser-apis/
  5. */
  6. // You can delete this file if you're not using it
  7. import React from 'react';
  8. import Layout from './src/components/layout';
  9. export const wrapPageElement = ({ element, props }) => <Layout {...props}>{element}</Layout>;
  10. export const onRouteUpdate = ({ location, prevLocation }) => {
  11. // console.log("new pathname", location.pathname)
  12. // console.log("old pathname", prevLocation ? prevLocation.pathname : null)
  13. };
  14. export const onPreRouteUpdate = ({ location, prevLocation }) => {
  15. // console.log("Gatsby started to change location to", location.pathname)
  16. // console.log("Gatsby started to change location from", prevLocation ? prevLocation.pathname : null)
  17. };
  18. export const shouldUpdateScroll = ({ routerProps: { location }, getSavedScrollPosition }) => {
  19. if (location.hash) {
  20. return false;
  21. }
  22. return true;
  23. };