Skip to content

Commit

Permalink
Merge pull request #25 from knovator/fix_onError-callback-calls
Browse files Browse the repository at this point in the history
fix `onError` callback calling multiple times for `Validation Error`
  • Loading branch information
chavda-bhavik committed Aug 24, 2022
2 parents 120bd7c + c8c1288 commit 5769944
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
8 changes: 1 addition & 7 deletions src/hook/useMaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,8 @@ const useMaster = ({ defaultLimit, routes, defaultSort = ["createdAt", 1], preCo
onSuccess(code, response?.code, response?.message)
getMastersList()
onCloseForm()
} else {
setLoading(false)
onError(code, response?.code, response?.message)
}
} catch (error) {
setLoading(false)
onError(code, INTERNAL_ERROR_CODE, (error as Error).message)
}
} catch (error) {}
}
const onCloseForm = () => {
setFormState(undefined)
Expand Down
8 changes: 1 addition & 7 deletions src/hook/useSubMaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,8 @@ const useSubMaster = ({ defaultLimit, routes, defaultSort = ["seq", 1], preConfi
onSuccess(code, response?.code, response?.message)
getSubMastersList()
onCloseForm()
} else {
setLoading(false)
onError(code, response?.code, response?.message)
}
} catch (error) {
setLoading(false)
onError(code, INTERNAL_ERROR_CODE, (error as Error).message)
}
} catch (error) {}
}
const onCloseForm = () => {
setFormState(undefined)
Expand Down

0 comments on commit 5769944

Please sign in to comment.