I have fetched data initially and based on the response deleted one from the database by clicking a button. Now I need to update UI/refetch data from the database. How do I do that? How do I handle state change and update UI using useSWR() React hook?
const fetcher = (url) => fetch(url).then((r) => r.json());
const { data, error } = useSWR("url", fetcher);
if (error) {
return "Error while loading data"
}
if (!data) {
return "data is loading";
}