Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

253
Visualizações
Server rendering with react-router v4 and prefetching data

I worked a lot with server side rendering with RR 3 so I wanted to see how it works in the context of v4. I followed the tutorial from the website, but because the rendering is happening now together with the route match, there's no way to implement prefetching data as before.

Here's how I used to do server rendering with v3: https://github.com/alexnm/react-seed/blob/master/server/index.js

Based on the match function, I would call all the prefetch functions from all the component tree and then wait with a Promise.all for them to finish, then trigger the renderToString function and return the html.

In RR4, we have only the <ServerRouter> component, so the current solution I came with is duplicating the render code: https://github.com/FortechRomania/react-redux-complete-example/blob/master/src/server/index.js

I'm also using the render function on the <Match> tag to trigger the prefetch actions. It's ugly and introduces all sorts of dependencies in the parent component of the page I want to render with prefetched data.

What am I missing here? Has anyone found a better solution for this scenario? I haven't found anything useful yet.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The new RR4 documentation has a working example: https://reacttraining.com/react-router/web/guides/server-rendering/data-loading

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda