FormidableLabs/react-ssr-prepass

why HTML node showing empty or undefined?

naveennsit opened this issue · 1 comments

I am checking this code to render react component on SSR
https://github.com/htdangkhoa/react-ssr-starter.

deployed latest code https://reactssrstarter.herokuapp.com/home

When I check source code HTML is not generated or In other words react component is not rendered on server

I try to debug issue below node coming undefined don't know why ?

const node = await ssrPrepass(
    <ChunkExtractorManager extractor={extractor}>
      <Provider store={store}>
        <StaticRouter location={req.url}>
          <HelmetProvider context={helmetContext}>
            <App />
          </HelmetProvider>
        </StaticRouter>
      </Provider>
    </ChunkExtractorManager>,
  );

  const markup = renderToString(node);

enter image description here

any idea ? ?

Please check the types and docs ✌️

Prepass does not return React elements and hence your const node variable is being set to undefined:

const renderPrepass = (element: Node, visitor?: Visitor): Promise<void> => {