Not understanding best practices
Hey, I am having a bit of trouble with my app. Here is the list:
1. Any time I do any basic crud operations my entire page reloads without calling router refresh or revalidatepath (trpc fetches again on any db write)
2. I have a component where I query data and pass that data into two separate client components, one that adds an issue, and one that displays the issues. When an issue is added I don't want to router.refresh every single time but I may have to in order to get the other client component to update.
3. Realtime functionality. This is a multi-tenancy system and I need to be able to add realtime funcationality to prevent race conditions when editing. Websockets for trpc seems very complicated when I look at it, and pusher channels don't work in trpc.
8 Replies
Code for problem #2:
Are you using any forms?
yeah, I will remove the unnecessary parts of the code for you:
there is more code in between but they are just dropdowns that let you select label status and priority
If that button is inside a form you need to specify
type="button"
otherwise it will reload the page on every clickno there is no form component
oh actually you were right
thats weird, its not in a form component but still reloading
type button fixed that issue
strange
do you have any tips on sharing the data between the components?
Could use jotai atoms if all the components are going to be sharing 1 state or context if its going to be contained within a reusable group of components