fix: update effect dependencies to use fetcher.data for improved error handling in dialogs

This commit is contained in:
Ardeman
2025-03-15 17:27:49 +08:00
parent e7ef7177ca
commit 7b840ce5cd
5 changed files with 13 additions and 13 deletions
+3 -3
View File
@@ -58,15 +58,15 @@ export const DialogRegister = () => {
const { handleSubmit, control } = formMethods
useEffect(() => {
if (!fetcher.data?.success) {
toast.error(fetcher.data?.message)
if (!fetcher.data?.success && fetcher.data?.message) {
toast.error(fetcher.data.message)
return
}
setIsRegisterOpen(false)
setIsSuccessOpen('register')
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fetcher])
}, [fetcher.data])
return (
<DialogNews