<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: jfn0</title>
    <description>The latest articles on Forem by jfn0 (@jfn0).</description>
    <link>https://forem.com/jfn0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F105691%2Fe59cb54c-8492-4b26-80fe-e818aa001b35.png</url>
      <title>Forem: jfn0</title>
      <link>https://forem.com/jfn0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/jfn0"/>
    <language>en</language>
    <item>
      <title>React SSR fetch per components</title>
      <dc:creator>jfn0</dc:creator>
      <pubDate>Tue, 12 Mar 2019 22:22:38 +0000</pubDate>
      <link>https://forem.com/jfn0/react-ssr-fetch-per-components-50gf</link>
      <guid>https://forem.com/jfn0/react-ssr-fetch-per-components-50gf</guid>
      <description>&lt;p&gt;Hi folk!&lt;/p&gt;

&lt;p&gt;After a lots of googling and reading regarding the best way to handle fetch per components in a SSR way I came to the conclusion that I need some React community help hehe.&lt;/p&gt;

&lt;p&gt;I tested razzle, nextjs, custom setup with express... and all the approaches follow the same pattern;&lt;/p&gt;

&lt;p&gt;1 Fetch all you data and &lt;br&gt;
2 pass it to the  &lt;br&gt;
3 render to string ...&lt;br&gt;
4 hydrate, &lt;em&gt;initial_state&lt;/em&gt; ... etc etc&lt;/p&gt;

&lt;p&gt;However, there is something that I do not like with this approach. I did a lot of SPA project in the past without caring about seo and being able to share page on facebook nor twitter, having Helmet changing my meta on the fly...&lt;/p&gt;

&lt;p&gt;But now, with this ssr way to do thing, not being able to fetch data in my component constructor... I feel that I have to break the way I am doing stuff.&lt;/p&gt;

&lt;p&gt;So the question, is there a way, to have a none ssr react spa project transfers to ssr without having to fetch all my data at the begining if favor to a per components approach like I did without ssr.&lt;/p&gt;

&lt;p&gt;side note:&lt;br&gt;
The closest I get is a try with JSDOM, where I am able to use Render( from react-dom in the server instead of renderToString... the downside with this approach is that I did not see any blog post exposing this approach. the other downside is I cannot know when all the components are done with theirs fetching, so I have to embed everything in a ; setTimeOut with a exagerated delay to be sure everything is done.&lt;/p&gt;

&lt;p&gt;Thank you&lt;/p&gt;

</description>
      <category>react</category>
      <category>ssr</category>
    </item>
  </channel>
</rss>
