Svelte createMutation mutates before mutate( ) #5055
Unanswered
danilockthar
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi 👋 I can't reproduce the issue using the sandbox you provided - are you still seeing the issue?
This might explain the behaviour you're seeing. I'm primarily a React user but you likely want to pass a reference to a function that calls - <button on:click={$addMutation.mutate()}
+ <button on:click={() => $addMutation.mutate({ name })} Let me know if you still need a hand 🙂 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! im following this example in the docs but its beheaving a little bit weird in my app.
https://codesandbox.io/s/github/tanstack/query/tree/main/examples/svelte/playground?from-embed=&file=/src/routes/AddTodo.svelte
right now im adding in my script the createMutation method
const addMutation = createMutation({ mutationFn: unsubscribe, onSuccess: (data) => { console.log(data) }, })
with some
<button on:click={$addMutation.mutate()}
but in the first render the mutates happens automatically, without clicking the button
someone can give me a hand ? thank you
Beta Was this translation helpful? Give feedback.
All reactions