Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ingeniousambivert opened this issue Jan 31, 2023 · 0 comments
Open

Comments

@ingeniousambivert
Copy link

ingeniousambivert commented Jan 31, 2023

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.

@ingeniousambivert ingeniousambivert changed the title useMutation doesn't update error/status state during the first mutation call useMutation doesn't update state during the first mutation call Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant