#Layout fetch keeps fetching

5 messages · Page 1 of 1 (latest)

muted sage
#

I have this layout component:

export default async function RootLayout({ children }: RootLayoutProps) {
  const { spaces } = await getSpaces();

If something changes in my Layout for example if I open a menu or something it keeps trying to fetch the data and the loading component appears, is there a way to improve this or am I doing something wrong?

getSpaces

Does following:

export const getSpaces = async () => {
  const { session } = await getUserAuth();
  const s = await db.select().from(spaces).where(eq(spaces.userId, session?.user.id!));

  return { spaces: s };
};
stray graniteBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

tired sandal
#

You shouldn’t fetch inside your layout. The layout is only for „layouting“ stuff. So fetch inside your pages. I think your problem is part of this principle 🙂 @muted sage

tired sandal
#

@muted sage solved?

tired sandal
#

@muted sage ?