Skip to content

Update useMutation memoization #166

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

Merged
merged 2 commits into from
Feb 27, 2020
Merged

Conversation

owinter86
Copy link
Contributor

@owinter86 owinter86 commented Feb 27, 2020

This will fix the issue identified here #165, however I am not sure if the check on the status in the useCallback was needed for a particular reason?

This will allow the mutation function to safely be included in a dependency array of an effect, like below.

const [mutate]  = useMutation(SOME_MUTATION);
React.useEffect(() => {
  mutate();
}, [mutate]);

Copy link
Collaborator

@tannerlinsley tannerlinsley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated

@tannerlinsley
Copy link
Collaborator

That multiline suggesting thing is trippy!

@owinter86
Copy link
Contributor Author

Yeah that works too.

@tannerlinsley
Copy link
Collaborator

Yeah, the check is to make sure the mutation is idle or an existing mutation is settled before allowing another one to to be triggered. We may not need it, but I'd like to keep it in until a use case comes along to remove it.

Copy link

nx-cloud bot commented Mar 22, 2024

View your CI Pipeline Execution ↗ for commit 3922bf8.

Command Status Duration Result
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2s View ↗
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-08 20:02:03 UTC

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

Successfully merging this pull request may close these issues.

2 participants