zustand empty on inital render
Hello,
I am currently using nextjs, trpc and zustand. I'm running into a problem where my zustand state is undefined on reacts inital render of the page.
- I use trpc's prefetch function is a layout.tsx file to fetch data on the server, the data here is used on all routes within my
- the data is being hydrated with trpcs hydrateclient comonent
- i have a loading.tsx file to catch all trpc queries which are still running, if there are any a loading state will be displayed until all data is fetched.
Here is my workspace selector component, it is at the top of my dashboard sidebar and shares state between different pages on the dashboard, which is why i plan on using zustand. I am only using zustand for the current selected workspace at this time, as I know trpc has a built in state management cache for data retrieved from the server.
I am currently using nextjs, trpc and zustand. I'm running into a problem where my zustand state is undefined on reacts inital render of the page.
- I use trpc's prefetch function is a layout.tsx file to fetch data on the server, the data here is used on all routes within my
/dashboard directory (this data is mainly for my dashboard sidebar- the data is being hydrated with trpcs hydrateclient comonent
- i have a loading.tsx file to catch all trpc queries which are still running, if there are any a loading state will be displayed until all data is fetched.
Here is my workspace selector component, it is at the top of my dashboard sidebar and shares state between different pages on the dashboard, which is why i plan on using zustand. I am only using zustand for the current selected workspace at this time, as I know trpc has a built in state management cache for data retrieved from the server.
