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

111
Visualizações
React.js: Delete operation and refresh page

I have implemented a delete operation. When this is done I make a redirect on the main page but I would like it to be automatically updated instead I have to update it again (calling a getEntities to get the values ​​back)

reducer.ts

export const getEntities = createAsyncThunk('services/getEntities', async (param: parameters) => {
  const requestUrl = `${apiUrl}${param.sortParam ? `?page=${param.pageParam}&size=${20}&sort=${param.sortParam}` : ''}`;
  const response = await axios.get<any>(requestUrl);
  return response;
});

export const deleteEntity = createAsyncThunk('services/deleteEntity', async (id: any) => {
  const response = await axios.delete<any>(`${apiUrl}/${id}`);
  return response;
})

deletePage.tsx

const handleClose = () => {
        props.history.push('/service');
    };


    const confirmDelete = () => {
        dispatch(deleteEntity(property.entity.id))
            .then((resp: any) => {
                if (resp.payload.status === 204) {
                    handleClose();
                }
            })
    };

So in my "service" page I have to call getEntities again to get the updated list (without the deleted element).

In your opinion How can I do to avoid having to manually call getEntities after deletion?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

By your props I'm guessing you're using react-router. To refresh a route you would use history.go(0).

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