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

willMount for server side rendering #95

Closed
viebel opened this issue Oct 13, 2017 · 9 comments
Closed

willMount for server side rendering #95

viebel opened this issue Oct 13, 2017 · 9 comments

Comments

@viebel
Copy link
Contributor

viebel commented Oct 13, 2017

In React Server side rendering, componentDidMount is not triggered.
On the other hand, ReasonReact doesn't have willMount but only didMount.

What can I do if I need componentDidMount in server side?

@chenglou
Copy link
Member

Can you also list one concrete use-case please? Just for reference

@viebel
Copy link
Contributor Author

viebel commented Oct 13, 2017

My use case is that I want to create component that updates the page title.
Something like that:
<Title title="my article" />

The implementation in client side to call the side-effect inside didMount.

But, didMount is not triggered in server side rendering.

@maarekj
Copy link

maarekj commented Oct 24, 2017

Do put the code in the constructor is enough?

@chenglou
Copy link
Member

Note that this wouldn't work with streaming, in reactjs, anyway

@maarekj
Copy link

maarekj commented Oct 31, 2017

Yes, but streaming is optional. No ?

@maarekj
Copy link

maarekj commented Dec 3, 2017

Finally it's planned to add willMount?

@nabati
Copy link

nabati commented Nov 9, 2018

My use case is that I want to create component that updates the page title.
Something like that:

<Title title="my article" />

Instead of imperatively updating the title once the component has been mounted, how about rendering the correct title from the beginning? This could possibly hint to somewhere where you could improve your design.

Also, in ReactJS, none of the lifecycle-hooks are run on server rendering AFAIK.

@maarekj
Copy link

maarekj commented Nov 12, 2018

Precisely, the lifecycle-hook UNSAFE_componentWillMount is the only lifecycle-hook to fire on the server, before the component is mounted.

https://reactjs.org/docs/react-component.html#unsafe_componentwillmount

@rickyvetter
Copy link
Contributor

I think SSR is fully supported with hooks. We aren’t planning on adding features to the record api.

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

5 participants