-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support dva ssr * feat: dva ssr * chore: umi beta 6 * chore: yarn.lock * fix: chore * chore: yarn.lock * chore: yarn.lock
- Loading branch information
信鑫-King
authored
May 19, 2020
1 parent
70ffc80
commit 9930e41
Showing
5 changed files
with
151 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
import React from 'react'; | ||
import { _DvaContainer } from './dva'; | ||
import { _DvaContainer, getApp, _onCreate } from './dva'; | ||
|
||
export function rootContainer(container) { | ||
return React.createElement(_DvaContainer, null, container); | ||
} | ||
|
||
{{#SSR}} | ||
export const ssr = { | ||
modifyGetInitialPropsCtx: async (ctx) => { | ||
// 服务端执行早于 constructor 中的 onCreate | ||
if (process.env.__IS_SERVER && ctx.history) { | ||
const tmpApp = _onCreate({ | ||
// server | ||
history: ctx.history, | ||
}) | ||
tmpApp.router(() => {}) | ||
tmpApp.start(); | ||
} | ||
// 一定有 app | ||
const { _store } = getApp(); | ||
ctx.store = _store; | ||
}, | ||
} | ||
{{/SSR}} |
Oops, something went wrong.