I have a handler function in my react project. I used hard reload to run the function.
const deleteTask = (index) => {
let tempList = taskList;
tempList.splice(index, 1);
localStorage.setItem("taskList", JSON.stringify(tempList));
setTaskList(tempList);
window.location.reload();
};
If I turn off the function:
window.location.reload();
Then I have to refresh the browser after I hit the delete button.
If so, what is the right solution so that I don’t have to refresh the browser when the delete button is pressed to delete data. Thanks.