refactor(react): fix a few more rules of hooks violations

This commit is contained in:
Elian Doran
2025-08-25 18:41:48 +03:00
parent 733ec2c145
commit 5a54dd666f
6 changed files with 27 additions and 18 deletions

View File

@@ -1,9 +1,9 @@
import { useRef } from "preact/hooks";
import { t } from "../../services/i18n";
import { useEffect } from "preact/hooks";
import note_autocomplete, { Options, type Suggestion } from "../../services/note_autocomplete";
import type { RefObject } from "preact";
import type { CSSProperties } from "preact/compat";
import { useSyncedRef } from "./hooks";
interface NoteAutocompleteProps {
id?: string;
@@ -19,8 +19,8 @@ interface NoteAutocompleteProps {
noteId?: string;
}
export default function NoteAutocomplete({ id, inputRef: _ref, text, placeholder, onChange, onTextChange, container, containerStyle, opts, noteId, noteIdChanged }: NoteAutocompleteProps) {
const ref = _ref ?? useRef<HTMLInputElement>(null);
export default function NoteAutocomplete({ id, inputRef: externalInputRef, text, placeholder, onChange, onTextChange, container, containerStyle, opts, noteId, noteIdChanged }: NoteAutocompleteProps) {
const ref = useSyncedRef<HTMLInputElement>(externalInputRef);
useEffect(() => {
if (!ref.current) return;