Skip to content

Commit

Permalink
add hook dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
js0mmer committed Oct 11, 2024
1 parent c418819 commit c0473ae
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions site/src/component/Review/Review.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useState, useEffect } from 'react';
import { FC, useState, useEffect, useCallback } from 'react';
import axios, { AxiosResponse } from 'axios';
import SubReview from './SubReview';
import ReviewForm from '../ReviewForm/ReviewForm';
Expand Down Expand Up @@ -28,7 +28,7 @@ const Review: FC<ReviewProps> = (props) => {
const [showOnlyVerifiedReviews, setShowOnlyVerifiedReviews] = useState(false);
const showForm = useAppSelector((state) => state.review.formOpen);

const getReviews = async () => {
const getReviews = useCallback(async () => {
interface paramsProps {
courseID?: string;
professorID?: string;
Expand All @@ -44,13 +44,13 @@ const Review: FC<ReviewProps> = (props) => {
const data = res.data.filter((review) => review !== null);
dispatch(setReviews(data));
});
};
}, [dispatch, props.course, props.professor]);

useEffect(() => {
// prevent reviews from carrying over
dispatch(setReviews([]));
getReviews();
}, [props.course?.id, props.professor?.ucinetid]);
}, [dispatch, getReviews]);

let sortedReviews: ReviewData[];
// filter verified if option is set
Expand Down

0 comments on commit c0473ae

Please sign in to comment.