onSuccess invalidate
I'm trying to follow along with Theo's T3 tutorial using the latest Next version and the app router. The "setInput("")" and the invalidation don't seem to be working inside of onSuccess, the console.log is being called, what am I missing? Is this supposed to work?
7 Replies
dependencies:
in the
input
component you are not setting the value property.
you need
Ahhh yeah this explains why the input wasn't being cleared, but my posts aren't updated, I need to manually refresh the page for my new post to appear
what posts? will need more context...
The CreatePost component creates a post when you submit the form:
then onSuccess in useMutation calls the invalidate on post.getAll which I assume should cause the getAll to fetch fresh posts
I dont know how
invalidate
works... but Im pretty sure the assumption is flawed...
you can use useQuery
& call the refetch
property within it on update of posts...
better would be to use query-keys
within usequery
which would trigger a fresh refetch
automaticallyHow to set trpc on next js 14, im lost in the documentsion
Please help me