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

146
Visualizações
Render react component after redirecting (Next.js, serversiderendering)

i'm new to next.js, and stucked in one problem i have some static links which are redirecting to search.tsx under pages folder

current behavior : now, if i click on any links , first it will wait for API response and then render search page

expected : - it should render first and then wait for API response

search.tsx

export const getServerSideProps = async (props: any) => {
    const apiResponse = await api.getProperties()
    return {
       props: {
       ...apiResponse,
   },
  }
}
const Search = (props: any) => {
  </searchResult>
}
export default Search
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

getServerSideProps runs whenever the page exporting this async function is requested, getServerSideProps is used for SSR, if you want to render the page and then fetch data, then you will have to do it in client side, you can use useEffect which can be used to fetch data because it only runs on the client side.

useEffect(()=>{
 async function fetchData(){
    // getch data fro API and set state

 },
fetchData()
},[])

refer here for more about getServerSideProps

about 4 years ago · Juan Pablo Isaza 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