fix(frontend): use ref to avoid stale movies closure in search (#103)

Co-authored-by: admin <admin@ardentleatherworks.com>
This commit is contained in:
Cody Kickertz 2025-12-21 12:27:41 -06:00 committed by GitHub
parent 80912b7d43
commit c07e5a697d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -134,6 +134,10 @@ function MovieSearchInput() {
const isLoading = useRef(false);
const requestValue = useRef<string | null>(null);
const requestLoadingRef = useRef(false);
const moviesRef = useRef(movies);
// Keep moviesRef current to avoid stale closure in debounced callback
moviesRef.current = movies;
const suggestionGroups = useMemo(() => {
const result: Section[] = [];
@ -203,7 +207,7 @@ function MovieSearchInput() {
const payload = {
value,
movies,
movies: moviesRef.current,
};
worker.current?.postMessage(payload);