From 540b9d91dd38c511d8615e89dd9b68a1de64e39e Mon Sep 17 00:00:00 2001 From: adueck Date: Fri, 17 Feb 2023 20:56:26 +0500 Subject: [PATCH] patch up for ssr compatiblity --- package-lock.json | 4 ++-- package.json | 2 +- src/components/package.json | 2 +- src/components/src/useStickyState.ts | 8 ++++++-- src/lib/package.json | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 60f0113..93483e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pashto-inflector", - "version": "5.7.16", + "version": "5.7.17", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pashto-inflector", - "version": "5.7.16", + "version": "5.7.17", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 9c9f72f..0b06708 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pashto-inflector", - "version": "5.7.16", + "version": "5.7.17", "author": "lingdocs.com", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "homepage": "https://verbs.lingdocs.com", diff --git a/src/components/package.json b/src/components/package.json index c90fc4c..44d4e64 100644 --- a/src/components/package.json +++ b/src/components/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/ps-react", - "version": "5.7.16", + "version": "5.7.17", "description": "Pashto inflector library module with React components", "main": "dist/components/library.js", "module": "dist/components/library.js", diff --git a/src/components/src/useStickyState.ts b/src/components/src/useStickyState.ts index f6ee9eb..cfa2c5c 100644 --- a/src/components/src/useStickyState.ts +++ b/src/components/src/useStickyState.ts @@ -15,7 +15,9 @@ export default function useStickyState(defaultValue: T | setValue: React.Dispatch>, ] { const [value, setValue] = useState(() => { - const v = window.localStorage.getItem(key); + const v = typeof window === "undefined" + ? null + : window.localStorage.getItem(key); // nothing saved if (v === null) { if (typeof defaultValue === "function") { @@ -39,7 +41,9 @@ export default function useStickyState(defaultValue: T | }); useEffect(() => { - window.localStorage.setItem(key, JSON.stringify(value)); + if (typeof window !== undefined) { + window.localStorage.setItem(key, JSON.stringify(value)); + } }, [key, value]); return [value, setValue]; diff --git a/src/lib/package.json b/src/lib/package.json index 0b6c51e..0f81249 100644 --- a/src/lib/package.json +++ b/src/lib/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/inflect", - "version": "5.7.16", + "version": "5.7.17", "description": "Pashto inflector library", "main": "dist/index.js", "types": "dist/lib/library.d.ts",