Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 8640b7f

Browse files
committed
HMR test on MST-models, but failed
1 parent 714c1ae commit 8640b7f

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

pages/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import { Provider } from 'mobx-react'
33

4-
import { initAppStore } from '../stores'
4+
import initAppStore from '../stores'
55
import Decrator from '../containers/Decrator'
66
import MultiLanguage from '../containers/MultiLanguage'
77
import Sidebar from '../containers/Sidebar'

pages/other.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Provider } from 'mobx-react'
33
import { IntlProvider } from 'react-intl'
44
import Link from 'next/link'
55

6-
import { initAppStore } from '../stores'
6+
import initAppStore from '../stores'
77

88
import globalStyles from '../utils/global_styles'
99
import Sidebar from '../containers/Sidebar'

stores/index.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,41 @@
33
*
44
*/
55

6-
// import { getSnapshot, applySnapshot } from 'mobx-state-tree'
6+
// import { onAction } from 'mobx-state-tree'
77

88
import AppStore from './AppStore'
99

10+
// export const appStore =
11+
1012
let appStore = null
1113

1214
const createRootStore = (isServer, langSetup) => {
1315
return AppStore.create({ appLangs: langSetup })
1416
}
1517

16-
export function initAppStore(isServer = false, langSetup) {
18+
function initAppStore(isServer = false, langSetup) {
1719
if (appStore === null) {
1820
appStore = createRootStore(isServer, langSetup)
1921
}
22+
23+
/*
24+
onAction(appStore, data => {
25+
console.log('onSnapshot: ', data)
26+
})
27+
*/
28+
2029
return appStore
2130
}
2231

23-
export const other = false
24-
// export default initAppStore
25-
32+
export default initAppStore
33+
// not work, TODO
2634
/*
2735
if (module.hot) {
2836
if (module.hot.data && module.hot.data.appStore) {
29-
console.log('applySnapshot appStore: ', appStore)
30-
console.log('applySnapshot: ', module.hot.data.appStore)
31-
// applySnapshot(appStore, module.hot.data.appStore)
37+
// applySnapshot(module.hot.data.old, module.hot.data.appStore)
3238
}
3339
module.hot.dispose(data => {
34-
console.log('dispose: data: ', getSnapshot(appStore))
35-
data.appStore = getSnapshot(appStore)
40+
// getSnapshot ...
3641
})
3742
}
3843
*/

0 commit comments

Comments
 (0)