@geee-be/react-utils 1.0.5 → 1.0.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @geee-be/react-utils
2
2
 
3
+ ## 1.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 59874a9: if (typeof history === 'undefined')
8
+
9
+ ## 1.0.6
10
+
11
+ ### Patch Changes
12
+
13
+ - 5aa7200: attempt to fix server error about missing history
14
+
3
15
  ## 1.0.5
4
16
 
5
17
  ### Patch Changes
@@ -2,6 +2,10 @@
2
2
  import { useEffect, useState } from 'react';
3
3
  import { deserialize, getInitialValue, serialize } from './state.util.js';
4
4
  export const useHistoryState = (key, initialValue, replace = true, options) => {
5
+ if (typeof history === 'undefined') {
6
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
7
+ return [undefined, () => { }];
8
+ }
5
9
  const [value, setValue] = useState(
6
10
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
7
11
  () => deserialize(history.state?.[key], options?.fromSerializable) ?? getInitialValue(initialValue));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geee-be/react-utils",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -11,6 +11,10 @@ export const useHistoryState = <T, S = T>(
11
11
  replace = true,
12
12
  options?: SerializationOptions<T, S>,
13
13
  ): [T, Dispatch<SetStateAction<T>>] => {
14
+ if (typeof history === 'undefined') {
15
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
16
+ return [undefined as any, () => {}];
17
+ }
14
18
  const [value, setValue] = useState<T>(
15
19
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
16
20
  () => deserialize(history.state?.[key], options?.fromSerializable) ?? getInitialValue(initialValue),