Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #468 (extra trial data) - update to prevent rerender #484

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/pages/benchmarks/[benchmark_id]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useEffect, useState, useRef } from "react";
import Counter from "@/components/counter/counter";
import ParaNav from "@/components/paraNav/ParaNav";
import Link from "next/link";
Expand Down Expand Up @@ -71,7 +71,7 @@ const BenchmarkPage = () => {
const [currentTrialIdx, setCurrentTrialIdx] = useState(0);
const currentTrial = task?.trials[currentTrialIdx] || null;

const [trialAdded, setTrialAdded] = useState(false);
const trialAddedRef = useRef<boolean>(false);

const hasInputChanged =
currentTrial?.notes !== notesInputValue ||
Expand Down Expand Up @@ -108,7 +108,7 @@ const BenchmarkPage = () => {
// Creates a new data collection instance (if there are none in progress)
useEffect(() => {
if (
!trialAdded &&
!trialAddedRef.current &&
!addTrialMutation.isLoading &&
!taskIsLoading &&
task &&
Expand All @@ -121,9 +121,9 @@ const BenchmarkPage = () => {
unsuccess: 0,
notes: "",
});
setTrialAdded(true);
trialAddedRef.current = true;
}
}, [task, addTrialMutation, taskIsLoading, trialAdded]);
}, [task, addTrialMutation, taskIsLoading]);

const handleUpdate = (updates: DataUpdate) => {
//Can only update if we're on the most recent trial
Expand Down
Loading