handleDelete: props => (id) => {
props.deleteClaim(id)
.then(() => {
message.success('success delete')
})
setTimeout(() => {
window.location.reload(true)
}, 1000)
},
the problem is that every time I run the delete function on page 2, I immediately return to the main page,
how to do it so that when reloading it can stay on page 2.
CodePudding user response:
Remove setTimeOut code cuz it makes you move to the main Page. "Re-load" means Browser re-load your whole page again which means Browser refresh your App and show you the main page again.
handleDelete: props => (id) => {
props.deleteClaim(id)
.then(() => {
message.success('success delete')
})
},
CodePudding user response:
I don't think reloading the page in React is a good idea as it fails the purpose of SPA (Single Page Application). If you want to keep yourself on the page 2 then why reloading in the first place? Upon delete, you might be thinking that the deleted object should be reflected on the front-end, so for that there can be two scenarios you can do:
- Either refetch your data
- Or delete that the object from your front-end list upon success of your API response