Skip to content

useMutation doesn't update state during the first mutation call #43

@monarchmaisuriya

Description

@monarchmaisuriya

Description

I am using the useMutation hook and I am experiencing an issue where the hook does not update the hook state after the first API request, and it does update it after subsequent API requests but with the previous call's result.

Steps to Reproduce

  • Import the useMutation hook from figbird into a React component
  • Call the patch() from hook in the component and observe that the state is not updated
  • Call it again without refreshing and observe that the state is updated

Expected Behavior

The useMutation hook should update the state after each API request.

Actual Behavior

The useMutation hook only updates the state after subsequent API requests with the previous API request's response, and not after the first API request.

Environment

node: 16.19.0
figbird: 0.11.1
React: 18.2.0
vite: 4.0.0

Usage

    const { patch, status, error } = useMutation(SERVICE);
    patch(id, payload);
    console.log("status, error ",status, error );
    // returns the null, idle after the first call, but changes in the second call 

Additional Information

The same thing works perfectly in useGet and useFind hooks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions