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

@@ -6,8 +6,7 @@ import { CSSProperties, memo } from "preact/compat";
import { useUniqueName } from "./hooks";
interface FormCheckboxProps {
id?: string;
name?: string;
name: string;
label: string | ComponentChildren;
/**
* If set, the checkbox label will be underlined and dotted, indicating a hint. When hovered, it will show the hint text.
@@ -19,9 +18,9 @@ interface FormCheckboxProps {
containerStyle?: CSSProperties;
}
const FormCheckbox = memo(({ name, id: _id, disabled, label, currentValue, onChange, hint, containerStyle }: FormCheckboxProps) => {
const id = _id ?? useUniqueName(name);
const FormCheckbox = memo(({ name, disabled, label, currentValue, onChange, hint, containerStyle }: FormCheckboxProps) => {
const labelRef = useRef<HTMLLabelElement>(null);
const id = useUniqueName(name);
// Fix: Move useEffect outside conditional
useEffect(() => {