Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
fix: do not violate rule of hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKohler committed Aug 9, 2021
1 parent a3eb3ff commit 9dc159d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions web/src/components/review-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@ type ReviewApproval = {
};

export default function SwipeReview(props: Props) {
const { onSkip, onReviewed, sentences, message, language } = props;
const { onSkip, onReviewed, sentences = [], message, language } = props;

const [currentSentenceIndex, setCurrentSentenceIndex] = useState(sentences.length - 1);
const [reviewedSentencesCount, setReviewedCount] = useState(0);
const [skippedSentencesCount, setSkippedSentencesCount] = useState(0);
const [reviewApproval, setReviewApproval] = useState<ReviewApproval>({});

if (!Array.isArray(sentences) || sentences.length === 0) {
return null;
}

const cardsRefs = useMemo(
() =>
Array(sentences.length)
Expand All @@ -39,6 +35,10 @@ export default function SwipeReview(props: Props) {
[]
);

if (sentences.length === 0) {
return null;
}

const APPROVAL_DIRECTIONS: Record<string, boolean> = {
left: false,
right: true,
Expand Down

0 comments on commit 9dc159d

Please sign in to comment.