Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit63053b9

Browse files
barbalexagilgur5
authored andcommitted
(fix): do not error if 'window' is undefined
- in certain environments like Node, 'window' will not be defined and so will cause mst-persist to error out on its check for localStorge, even if a different storage engine were configured- this fix enables usage in Node environments, supporting usage like hydrating server-side
1 parentbd37065 commit63053b9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

‎src/index.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ type StrToAnyMap = {[key: string]: any}
1616
exportconstpersist:IArgs=(name,store,options={})=>{
1717
let{storage, jsonify, whitelist, blacklist}=options
1818

19-
if(typeofwindow.localStorage!=='undefined'&&(!storage||storage===window.localStorage)){
19+
// use AsyncLocalStorage by default (or if localStorage was passed in)
20+
if(
21+
typeofwindow!=='undefined'&&
22+
typeofwindow.localStorage!=='undefined'&&
23+
(!storage||storage===window.localStorage)
24+
){
2025
storage=AsyncLocalStorage
2126
}
2227
if(!jsonify){jsonify=true}// default to true like mobx-persist

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp