Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

useMutation on success function not being called

const { mutate } = useAddFAQPost()

    const onSubmit = useCallback((event: React.ChangeEvent<FormEvent>) => { 
        event.preventDefault();
        return mutate({ title, type } as FAQ), {
            onSuccess: async (data: string, context: string) => {
                console.log(data);
                console.log('why not?');
            },
            onError: async (data: string, context: string) => {
                console.log(data);
            },
            onSettled: () => {
              //Some unmounting action.
              //eg: if you have a form in a popup or modal -> call your close modal method here.
              // onSettled will trigger once the mutation is done either its succeeds or errors out.
            }
        };
    }, [title, type])
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: pipefy api search card field 
Javascript :: how to get the contract address from the contract instance web3js 
Javascript :: javascript dom last child 
Javascript :: open route in new tab vue router 
Javascript :: remove undefined from array javascript 
Javascript :: react native community eslint 
Javascript :: javascript regex check if string is empty 
Javascript :: this.$set 
Javascript :: javascript get object from array where property equals 
Javascript :: js contains class 
Javascript :: vue call method after delay 
Javascript :: get the size of the screen javascript 
Javascript :: discord javascript how to create a role 
Javascript :: node run parameters 
Javascript :: router class in backbone 
Javascript :: javascript append how first element 
Javascript :: socket io get ip 
Javascript :: inline style vue 
Javascript :: create hash in node js 
Javascript :: js set cookie 
Javascript :: angular generate component 
Javascript :: redis json get multiple paths 
Javascript :: scroll to bottom of an element react 
Javascript :: js add seconds to current time 
Javascript :: js separate number with comma 
Javascript :: github authorization javascript 
Javascript :: p5js class 
Javascript :: how to get current day in javascript 
Javascript :: nodejs print variable in string 
Javascript :: can immigrants vote in uk 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =