Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/gatsby-react-router-scroll/src/StateStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class SessionStorage {
const stateKey = this.getStateKey(location, key)

try {
const value = sessionStorage.getItem(stateKey)
const value = window.sessionStorage.getItem(stateKey)
return JSON.parse(value)
} catch (e) {
console.warn(
Expand All @@ -30,7 +30,7 @@ export default class SessionStorage {
const storedValue = JSON.stringify(value)

try {
sessionStorage.setItem(stateKey, storedValue)
window.sessionStorage.setItem(stateKey, storedValue)
} catch (e) {
if (window && window[GATSBY_ROUTER_SCROLL_STATE]) {
window[GATSBY_ROUTER_SCROLL_STATE][stateKey] = JSON.parse(storedValue)
Expand All @@ -46,8 +46,7 @@ export default class SessionStorage {
}

getStateKey(location, key) {
const locationKey = location.key
const stateKeyBase = `${STATE_KEY_PREFIX}${locationKey}`
const stateKeyBase = `${STATE_KEY_PREFIX}${location.pathname}`
return key === null || typeof key === `undefined`
? stateKeyBase
: `${stateKeyBase}|${key}`
Expand Down