-
Notifications
You must be signed in to change notification settings - Fork 660
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
Add possibility to make Helmet Component Class on demand #296
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #296 +/- ##
==========================================
+ Coverage 98.94% 98.95% +<.01%
==========================================
Files 3 3
Lines 285 287 +2
==========================================
+ Hits 282 284 +2
Misses 3 3
Continue to review full report at Codecov.
|
@pristas-peter Do you think this will work with React 16, |
yes, already using it. |
@pristas-peter how are you passing the Helmet instance around to children, through context? |
@pristas-peter Can you add an example to show how it works with React 16, |
I would love to see an example of how you're using this @pristas-peter |
Sorry to reply so late...
Hope it is somehow clear, feel free to ask any questions Edit: the code is also universal, on client we just pass the "Helmet element" to render function of the root element |
So you're rendering twice on the server? Once via renderToStaticMarkup for side effects and once so you can stream the response down to the client? I'm curious, why stream at all if you already have the HTML and can send that down to your users? |
No, not twice... RenderToStaticMarkup is only run on a small helmet element |
@pristas-peter Thanks for the idea of solving this issue! It just works for me without separate instance, and I don't see any reasons for race conditions. Maybe I'm missing something? |
try to simulate very high number of simultaneous requests, I know that that the probability isn't that hight that the context switch of node process switches between inside rendering two helmet elements, but chance is still there, but very minimal, but it can happen... |
Is it possible to use react-helmet with react-router while streaming html via |
@vsc-github, see this comment in issue 322 for an alternative implementation with react-router. Internally it uses a modified version of react-helmet. The API is extremely different to react-helmet so it may not suit your needs, but it does support SSR with streams. |
This PR was created on 21 Jun 2017. Can somebody comment if this can be merged? |
Any update on this? thanks |
We are streaming server response (not using ReactDomServer.renderToString) and we need singleton instance of Helmet Component Class per each request since it is using static variable on wrapped component (streaming is async, so there could be race conditions)...