Skip to content

Commit

Permalink
mobile: BookInfoModalReview: refresh on focus
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswpark committed Apr 20, 2024
1 parent d826172 commit 7181fe6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mobile/Components/BookInfoModalReview/BookInfoModalReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ActivityIndicator, FlatList, Text, View } from "react-native";
import FontAwesome from "react-native-vector-icons/FontAwesome";
import useSWR from "swr";
import BookInfoReviewItem from "../BookInfoReviewItem";
import { useFocusEffect } from "@react-navigation/native";

const account = new Account(client);
const databases = new Databases(client);
Expand Down Expand Up @@ -111,6 +112,12 @@ export const BookInfoModalReview = ({ bookInfo, navigation }) => {
const { data, error, isLoading, mutate } = useSWR(bookInfo.id, getReviews);
const [averageRating, setAverageRating] = React.useState(0);

useFocusEffect(
React.useCallback(() => {
mutate();
}, [mutate]),
);

React.useEffect(() => {
if (!isLoading && data) {
let totalRating = 0;
Expand Down

0 comments on commit 7181fe6

Please sign in to comment.