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

Change from componentWillMount to componentDidMount #6

Closed
cusspvz opened this issue May 30, 2016 · 6 comments
Closed

Change from componentWillMount to componentDidMount #6

cusspvz opened this issue May 30, 2016 · 6 comments

Comments

@cusspvz
Copy link

cusspvz commented May 30, 2016

So we can make this compatible with Universal JS, we must ensure the styles code aren't run on the server side. As server executes componentWillMount, the better would be to change the useability check to the componentDidMount hook on the Component's life cycle.

@bloodyowl
Copy link
Owner

if we use componentDidMount, there might be a flash of unstyled content (w/ webpack you can use ExtractTextPlugin on the server to extract CSS contents and inject it somewhere else)

@cusspvz
Copy link
Author

cusspvz commented May 30, 2016

Could this be an option?

@bloodyowl
Copy link
Owner

well, if you render your components on the server, I guess you want the right styles to be in the page on initial load, right?

componentDidMount isn't called with ReactDOMServer, which means the server wouldn't have any idea which CSS to put in the page initially

@cusspvz
Copy link
Author

cusspvz commented Jun 1, 2016

But are you shipping the CSS from the server?

@cusspvz
Copy link
Author

cusspvz commented Jun 1, 2016

On the project I'm using this I have webpack handling both server and browser builds, on the server build I've attached the null-loader instead, because the server won't ever build a DOM, neither the style-loader/useable would work on the server, or am I wrong? 😕

@cusspvz
Copy link
Author

cusspvz commented Jun 1, 2016

PS: Even if you are loading CSS on the server for you to know which classes you need to render, you won't need to call use(), I'm really interested to know how you've builded or shipped CSS from within the server. On every scenarios I'm thinking on, I'm supposing it would give errors, memory leaks or bottlenecks.

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