fix: added useCallback for controlling debounce function triggering on every rerendeer

Added a useCallback function, which helps keeping only one version of the debounce function, what happens is that when we type in the editor, the rerenders produces multiple debounce function, which all triggers together after the specifier amount of time, making many request to backend, consiquently failing the debounce. Now useCallback will give only one function even if the rerenders are happening which fixes the issue
This commit is contained in:
Henit Chobisa 2023-12-08 16:44:42 +05:30 committed by rahulramesha
parent b82f04ea04
commit 01874cb2db

View File

@ -328,6 +328,7 @@ const PageDetailsPage: NextPageWithLayout = observer(() => {
description_html: "", description_html: "",
}); });
// ADDING updatePage TO DEPENDENCY ARRAY PRODUCES ADVERSE EFFECTS
const debouncedFormSave = useCallback( const debouncedFormSave = useCallback(
debounce(async () => { debounce(async () => {
handleSubmit(updatePage)().finally(() => setIsSubmitting("submitted")); handleSubmit(updatePage)().finally(() => setIsSubmitting("submitted"));