patch up for ssr compatiblity
This commit is contained in:
parent
fc8142b56e
commit
540b9d91dd
|
@ -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": {
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -15,7 +15,9 @@ export default function useStickyState<T extends SaveableData>(defaultValue: T |
|
|||
setValue: React.Dispatch<React.SetStateAction<T>>,
|
||||
] {
|
||||
const [value, setValue] = useState<T>(() => {
|
||||
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<T extends SaveableData>(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];
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue