Skip to content

Commit

Permalink
fix: restore staicRouter
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyuang committed Nov 22, 2021
1 parent a88956e commit 1150a6c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions packages/plugin-react/src/entry/server-entry.tsx
@@ -1,4 +1,5 @@
import * as React from 'react'
import { StaticRouter } from 'react-router-dom'
import { findRoute, getManifest, logGreen, normalizePath, addAsyncChunk } from 'ssr-server-utils'
import { ISSRContext, IGlobal, IConfig, ReactRoutesType, ReactESMFeRouteItem } from 'ssr-types-react'
import * as serialize from 'serialize-javascript'
Expand Down Expand Up @@ -109,11 +110,13 @@ const serverRender = async (ctx: ISSRContext, config: IConfig): Promise<React.Re
}} />

return (
<Context.Provider value={{ state: combineData }}>
<Layout ctx={ctx} config={config} staticList={staticList} injectState={injectState}>
{isCsr ? <></> : <Component />}
</Layout>
</Context.Provider>
<StaticRouter>
<Context.Provider value={{ state: combineData }}>
<Layout ctx={ctx} config={config} staticList={staticList} injectState={injectState}>
{isCsr ? <></> : <Component />}
</Layout>
</Context.Provider>
</StaticRouter>
)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/config.ts
Expand Up @@ -53,7 +53,7 @@ export interface IConfig {
customeHeadScript?: (ctx: ISSRContext) => Script | Script
customeFooterScript?: (ctx: ISSRContext) => Script | Script
locale?: {
enable: false
enable: boolean
}
ssrVueLoaderOptions?: any
csrVueLoaderOptions?: any
Expand Down

0 comments on commit 1150a6c

Please sign in to comment.