Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda