Skip to content

Commit 4051323

Browse files
authored
fix(ssr-react): remove context from render (#276)
1 parent c3d2ffa commit 4051323

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

playground/ssr-react/prerender.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ const routesToPrerender = fs
2222
;(async () => {
2323
// pre-render each route...
2424
for (const url of routesToPrerender) {
25-
const context = {}
26-
const appHtml = await render(url, context)
25+
const appHtml = await render(url)
2726

2827
const html = template.replace(`<!--app-html-->`, appHtml)
2928

playground/ssr-react/server.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,7 @@ export async function createServer(
7373
render = (await import('./dist/server/entry-server.js')).render
7474
}
7575

76-
const context = {}
77-
const appHtml = render(url, context)
78-
79-
if (context.url) {
80-
// Somewhere a `<Redirect>` was rendered
81-
return res.redirect(301, context.url)
82-
}
76+
const appHtml = render(url)
8377

8478
const html = template.replace(`<!--app-html-->`, appHtml)
8579

playground/ssr-react/src/entry-server.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import ReactDOMServer from 'react-dom/server'
22
import { StaticRouter } from 'react-router-dom/server'
33
import { App } from './App'
44

5-
export function render(url, context) {
5+
export function render(url) {
66
return ReactDOMServer.renderToString(
7-
<StaticRouter location={url} context={context}>
7+
<StaticRouter location={url}>
88
<App />
99
</StaticRouter>,
1010
)

0 commit comments

Comments
 (0)