Skip to content

fix(ssr-react): remove context from render #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions playground/ssr-react/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ const routesToPrerender = fs
;(async () => {
// pre-render each route...
for (const url of routesToPrerender) {
const context = {}
const appHtml = await render(url, context)
const appHtml = await render(url)

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

Expand Down
8 changes: 1 addition & 7 deletions playground/ssr-react/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,7 @@ export async function createServer(
render = (await import('./dist/server/entry-server.js')).render
}

const context = {}
const appHtml = render(url, context)

if (context.url) {
// Somewhere a `<Redirect>` was rendered
return res.redirect(301, context.url)
}
const appHtml = render(url)

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

Expand Down
4 changes: 2 additions & 2 deletions playground/ssr-react/src/entry-server.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import ReactDOMServer from 'react-dom/server'
import { StaticRouter } from 'react-router-dom/server'
import { App } from './App'

export function render(url, context) {
export function render(url) {
return ReactDOMServer.renderToString(
<StaticRouter location={url} context={context}>
<StaticRouter location={url}>
<App />
</StaticRouter>,
)
Expand Down