Skip to content

Commit

Permalink
fix: fix ssr-with-mob close #110
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyuang committed Nov 26, 2019
1 parent e9c049e commit d0279fa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions example/ssr-with-mobx/web/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import { Provider, useStaticRendering } from 'mobx-react'
import initStore from './store'

const clientRender = async () => {
const store = initStore({
const store = window.store || initStore({
__isBrowser__: __isBrowser__,
initialState: window.__INITIAL_DATA__ || {}
initialState: window.__INITIAL_DATA__
})
window.store = store
// 客户端渲染||hydrate
ReactDOM[window.__USE_SSR__ ? 'hydrate' : 'render'](
<Provider store={store}>
Expand Down
2 changes: 1 addition & 1 deletion example/ssr-with-mobx/web/store/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class NewsStore {
@observable detail = ''
constructor (state) {
this.detail = (state && state.newsStore && state.newsStore.detail) || ''
this.detail = state ? state.newsStore.detail : ''
}

@action
Expand Down
2 changes: 1 addition & 1 deletion example/ssr-with-mobx/web/store/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PageStore {
@observable news = []

constructor (state) {
this.news = (state && state.pageStore && state.pageStore.news) || []
this.news = state ? state.pageStore.news : []
}

@action
Expand Down

0 comments on commit d0279fa

Please sign in to comment.