@rpcbase/client 0.169.0 → 0.170.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hashState.js +4 -2
- package/package.json +1 -1
package/hashState.js
CHANGED
|
@@ -12,7 +12,7 @@ const PAGE_NAVIGATION_EVENT = "RB_PAGE_NAVIGATION"
|
|
|
12
12
|
const EMPTY_STATE_TOKEN = "N4XyA" // lz-string encoded empty state ''
|
|
13
13
|
|
|
14
14
|
// WARNING: this assumes hash_str starts with "#"
|
|
15
|
-
const parse_hash_str = (hash_str = window
|
|
15
|
+
const parse_hash_str = (hash_str = window?.location?.hash || "") => {
|
|
16
16
|
if (hash_str.length < 1) {
|
|
17
17
|
return {}
|
|
18
18
|
}
|
|
@@ -38,6 +38,8 @@ export const encodeHashState = (payload) =>
|
|
|
38
38
|
const apply_hash_state = (payload) => {
|
|
39
39
|
const str = encodeHashState(payload)
|
|
40
40
|
|
|
41
|
+
if (!history) return
|
|
42
|
+
|
|
41
43
|
if (str === EMPTY_STATE_TOKEN) {
|
|
42
44
|
history.replaceState(null, null, window.location.pathname + window.location.search)
|
|
43
45
|
} else {
|
|
@@ -99,7 +101,7 @@ export const HashStateProvider = ({children}) => {
|
|
|
99
101
|
|
|
100
102
|
useEffect(() => {
|
|
101
103
|
apply_hash_state(hashState)
|
|
102
|
-
window.
|
|
104
|
+
window.__PRIVATE_HASH_STATE_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = hashState
|
|
103
105
|
}, [hashState])
|
|
104
106
|
|
|
105
107
|
const serializeHashState = useCallback((payload) => {
|