Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
React.js: Eliminar operación y actualizar página

He implementado una operación de eliminación. Cuando termine, realizo una redirección en la página principal, pero me gustaría que se actualice automáticamente, en lugar de eso, tengo que actualizarlo nuevamente (llamando a getEntities para recuperar los valores)

reductor.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; })

eliminarPágina.tsx

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

Entonces, en mi página de "servicio", tengo que volver a llamar a getEntities para obtener la lista actualizada (sin el elemento eliminado).

En su opinión, ¿cómo puedo hacer para evitar tener que llamar manualmente a getEntities después de la eliminación?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Por tus props , supongo que estás usando react-router . Para actualizar una ruta, usaría history.go(0) .

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!