Skip to content

Commit f446bf5

Browse files
committed
Bug | fixing reranker not have updated state of algo finished
1 parent 814d75b commit f446bf5

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/components/map-projects/MapProject.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,10 @@ const MapProject = () => {
219219
const rowStageRef = React.useRef([]);
220220
const [, _setRowStage] = React.useState({}) // {'0': {'algo1': -2, -1, 0, 1, 'rerank': -2, -1, 0, 1}} --> -2: failed, -1: not run yet, 0: running, 1: done
221221
const setRowStage = React.useCallback((updater) => {
222-
_setRowStage(prev => {
223-
const next = typeof updater === "function" ? updater(prev) : updater;
224-
rowStageRef.current = next; // ✅ always in sync with the committed update
225-
return next;
226-
});
222+
const next = typeof updater === "function" ? updater(rowStageRef.current) : updater;
223+
// Keep the ref in lockstep with imperative consumers like rerank checks.
224+
rowStageRef.current = next;
225+
_setRowStage(next);
227226
}, []);
228227

229228
const allCandidatesRef = React.useRef({})

0 commit comments

Comments
 (0)