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

109
Visualizações
Preventing Apollo useQuery from re-running during a modal component being opened

I am fetching some data using Apollo useQuery in a Profile component which is a parent component.

const { data: postsData, error: postsError } = useQuery(GET_POSTS_FROM_USER, { variables: { userId: userIdFromRouter } })

Inside Profile I have a nav with an option open a dialog to create a new post which sits on top of the component in a modal

{!showPosts ? (<ProfilePageNavHeader currentUser={currentUser.currentUser} userIdFromRouter={userIdFromRouter} />) : null}

ProfilePageNavHeader

        <nav className={profileHeaderStyles.nav}>
          <div>
            <h2>{currentUser.userName}</h2>
          </div>
          <ul>
            <li>
              <MdOutlineAddBox onClick={handleShowNewPostModal} />
            </li>
            <li>
              <FiLogOut onClick={handleUserLogOut} />
            </li>
          </ul>
          {newPostModal ? (
            <FileUpload open={newPostModal} handleClose={handleCloseNewPostModal} />
          ) : null}
        </nav>
  const handleShowNewPostModal = () => {
    setNewPostModal(true);
  };

The problem im having is that everytime handleShowNewPostModal I see the useQuery is refetching. I know there is a skip option but im not sure if this applies to my specific use case, because I need the data to fetch once, but then not fetch again if I am opening that modal, and I need the data that has already been fetched to continue sitting there. Any help woulld be great thanks.

about 4 years ago · Santiago Trujillo
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