fix: react-doctor exhaustive-deps 3→0, prefer-use-effect-event 3→0 (useEffectEvent for modal cancel handlers), role-supports-aria-props 3→0 (aria-pressed/aria-current on buttons)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import { useState, useEffect, useRef, useEffectEvent } from "react";
|
||||
import Image from "next/image";
|
||||
import { LotDetail } from "@/actions/route-trace/lots";
|
||||
|
||||
@@ -91,16 +91,20 @@ export default function StickerPreviewModal({ lot, onClose }: { lot: LotDetail;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const onCloseEvent = useEffectEvent(() => {
|
||||
onClose();
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const dialog = dialogRef.current;
|
||||
if (!dialog) return;
|
||||
const handleCancel = (e: Event) => {
|
||||
e.preventDefault();
|
||||
onClose();
|
||||
onCloseEvent();
|
||||
};
|
||||
dialog.addEventListener("cancel", handleCancel);
|
||||
return () => dialog.removeEventListener("cancel", handleCancel);
|
||||
}, [onClose]);
|
||||
}, []);
|
||||
|
||||
const handleBackdropClick = (e: React.MouseEvent) => {
|
||||
const dialog = dialogRef.current;
|
||||
|
||||
Reference in New Issue
Block a user