DEV Community

Discussion on: My approach to SSR and useEffect - discussion

Collapse
 
kmoskwiak profile image
Kasper Moskwiak

Thanks for the link, it looks very exiting. I'll try to make some examples with this new API combined with useSEE. I have to dive into this a little bit...

However my first thought is that useSEE will still need two renders. The new pipeToNodeWritable will just replace renderToNodeStream in second render.

Collapse
 
vengeurmasque78 profile image
TheVengeurMasque

From what I understand in Dan's abramov demo, the component wrapped within suspense is not rendered. If you inspect the page, you won't see any html.
React 18 does not have to wait for all promises to resolve.
When a promise resolve, it will then render the code server side and "inject it" on the client. That's the beauty of it. It solves the waterfall issue if I understood correctly.
Though Dan abramov said they have not implemented the data fetching mechanism.
Does useSEE fetch data twice (server + client) ? From what you wrote, you said that data will be available in the global context.
So I guess we have to check if data exist in the global context we fetch or we don't
Something like

const [data] = useSSE(
    {},
    "my_article",
    () => {
      if (!fetchedData) {
      return fetch('http://articles-api.example.com').then((res) => res.json());
      }
    },
    []
  );
Enter fullscreen mode Exit fullscreen mode