Next.js Discord

Discord Forum

refetching on server component after some action

Unanswered
Japanese pilchard posted this in #help-forum
Open in Discord
Avatar
Japanese pilchardOP
  const section = await api.course.getCourseSection.query({
    sectionId: parseInt(params.lesson),
  });


I need to refetch this when some button is clicked (or if easier, when some query string param is changed), but this component NEEDS to be a server component unfortunately. How can I revalidate this tRPC call?

8 Replies

Avatar
Dunker
do you have an idea to use server actions in client components 😄
i fixed it like, not with server actions or rsc
- useEffect -
  getData
- --------- -

- handleSubmit -
send data to db 
  getData
Avatar
Japanese pilchardOP
i vaguely do but I haven't used server actions before. do u think that would solve my problem? I feel like I'm trying to use section like useState, but I mean, I just have to set it once and just refetch so I this sounds doable in my implementation
and the weirder thing is... when I add or delete from the table that I add mutate in the client components manually, it infact does refetch the data, so section becomes the correct value, however, when the client component inserts, it does not refetch
I'll send a video
Avatar
Dunker
then revalidate in action
action(){
  "use server"
  ...
  revalidatePath/Tag(url)
}
tbh even v13 is still new and we need a lot time to solve it