forked from DouyinFE/semi-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-browser.js
30 lines (23 loc) · 958 Bytes
/
gatsby-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* Implement Gatsby's Browser APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/browser-apis/
*/
// You can delete this file if you're not using it
import React from 'react';
import Layout from './src/components/layout';
export const wrapPageElement = ({ element, props }) => <Layout {...props}>{element}</Layout>;
export const onRouteUpdate = ({ location, prevLocation }) => {
// console.log("new pathname", location.pathname)
// console.log("old pathname", prevLocation ? prevLocation.pathname : null)
};
export const onPreRouteUpdate = ({ location, prevLocation }) => {
// console.log("Gatsby started to change location to", location.pathname)
// console.log("Gatsby started to change location from", prevLocation ? prevLocation.pathname : null)
};
export const shouldUpdateScroll = ({ routerProps: { location }, getSavedScrollPosition }) => {
if (location.hash) {
return false;
}
return true;
};