Skip to content
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

How would server-side rendering work? #1

Closed
jrf0110 opened this issue Apr 11, 2018 · 1 comment
Closed

How would server-side rendering work? #1

jrf0110 opened this issue Apr 11, 2018 · 1 comment

Comments

@jrf0110
Copy link

jrf0110 commented Apr 11, 2018

I'm looking to use this on a couple of projects that do server rendering. Those projects do something like:

const appStr = renderToString(<App />)
res.end(`
<!DOCTYPE html>
<html>
  <head>
    <title>${howDoesReactTitledPutTheTitleHere}</title>
  </head>
  <body>
    ${appStr}
  </body>
</html>
`)

Is there an existing mechanism for this?

@tajo
Copy link
Owner

tajo commented Apr 12, 2018

I was thinking about it. It seems that the only way would be to implement UNSAFE_componentWillMount since that's afaik the only lifecycle method that's being called during SSR. titled now uses only componentDidMount, DidUpdate and WillIUnmount.

There is a lengthy discussion (including React team) about this here. It seems the solution is to use UCWM on the server until reactjs/rfcs#8 lands.

@tajo tajo closed this as completed Sep 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants