fix: improper handling of undefined api leading to crashes

This commit is contained in:
Prayag Prajapati committed 2024-11-25 00:11:53 +05:30
1 parent c6b5d6a4a2
commit 81695a583d
9 files changed
+73 -67

No files matched your search

@@ -8,15 +8,10 @@ import React from "react";
const PlayPreviousButton = () => {
const api = useApiInContext((s) => s.api);
if (!api) {
console.error(
"Unable to display play previous button, api is not available",
);
return null;
}
const user = useQuery({
queryKey: ["user"],
queryFn: async () => {
if (!api) return;
const result = await getUserApi(api).getCurrentUser();
return result.data;
},