This repository was archived by the owner on Mar 11, 2021. It is now read-only.
File tree 6 files changed +921
-947
lines changed
6 files changed +921
-947
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- "presets" : [" next/babel" ],
2
+ "presets" : [
3
+ [
4
+ " next/babel" ,
5
+ {
6
+ "preset-env" : {
7
+ "useBuiltIns" : " usage"
8
+ },
9
+ "transform-runtime" : {
10
+ "corejs" : false ,
11
+ "helpers" : false
12
+ }
13
+ }
14
+ ]
15
+ ],
3
16
"plugins" : [
4
17
[" @babel/plugin-proposal-decorators" , {"legacy" : true }],
5
18
[" @babel/plugin-proposal-class-properties" , {"loose" : true }]
Original file line number Diff line number Diff line change 14
14
"build" : " npm run clean && npm run babel" ,
15
15
"prepublishOnly" : " npm run build"
16
16
},
17
+ "dependencies" : {},
17
18
"devDependencies" : {
18
19
"@babel/cli" : " ^7.2.3" ,
19
20
"@babel/core" : " ^7.2.2" ,
20
21
"@babel/plugin-proposal-class-properties" : " ^7.3.0" ,
21
22
"@babel/plugin-proposal-decorators" : " ^7.3.0" ,
22
- "next" : " ^7 .0.2 " ,
23
- "react" : " ^16.7.0 " ,
23
+ "next" : " ^8 .0.1 " ,
24
+ "react" : " ^16.8.1 " ,
24
25
"rimraf" : " ^2.6.3"
25
26
},
26
27
"peerDependencies" : {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ const __NEXT_MOBX_STORE__ = new Map();
6
6
export class BaseStore {
7
7
constructor ( props = { } ) {
8
8
for ( const prop in props ) {
9
- // Convert JSON string to Map string for client
9
+ // Convert JSON to Map
10
10
this [ prop ] = jsonToMap ( props [ prop ] ) ;
11
11
}
12
12
}
@@ -19,24 +19,25 @@ export class BaseStore {
19
19
}
20
20
21
21
export const getOrCreateStore = ( storeKeyName , Store ) => initialState => {
22
- // Convert Map to JSON string for client
22
+ // Convert Map to JSON
23
23
if ( initialState ) {
24
24
for ( const itemState in initialState ) {
25
25
try {
26
26
const dataMap = initialState [ itemState ] ;
27
+
27
28
if ( dataMap . toJS ( ) instanceof Map ) {
28
29
initialState [ itemState ] = mapToJson ( dataMap ) ;
29
30
}
30
31
} catch ( e ) { }
31
32
}
32
33
}
33
34
34
- // Always make a new store if server, otherwise state is shared between requests
35
+ // Always make a new store if server
35
36
if ( isServer ) {
36
37
return new Store ( initialState ) ;
37
38
}
38
39
39
- // Create store if unavailable on the client and set it on the window object
40
+ // Create store if unavailable on the client
40
41
if ( ! __NEXT_MOBX_STORE__ . has ( storeKeyName ) ) {
41
42
__NEXT_MOBX_STORE__ . set ( storeKeyName , new Store ( initialState ) ) ;
42
43
}
Original file line number Diff line number Diff line change 1
1
export const isServer = ! process . browser ;
2
2
3
- // getCounterStore=> counterStore
3
+ // getCounterStore => counterStore
4
4
export const getKeyNameStore = fnName =>
5
5
fnName . replace ( / ^ g e t ( .) / , ( match , p1 ) => p1 . toLowerCase ( ) ) ;
6
6
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ export default (getStores = {}) => App => {
38
38
39
39
render ( ) {
40
40
const { initialMobxState, ...props } = this . props ;
41
+
41
42
return < App { ...props } store = { { ...this . store } } /> ;
42
43
}
43
44
} ;
You can’t perform that action at this time.
0 commit comments