Next.js Discord

Discord Forum

reloading countless times

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
I have a server function that returns from a database using prisma but it reloads page thousands of times for no reason

13 Replies

Polar bearOP
"use server";

import prisma from "@/lib/prisma";

export type TStudent = {
    name: string,
    password: string,
    image: string,
  }
  

export async function returnStudents() {
    const rinder: Array<TStudent> = await prisma.student.findMany();

    return rinder;
};
  const students: Array<TStudent>  = await returnStudents();
this is how i use it on the client
@Polar bear this is how i use it on the client
both things u showed only work on rsc
also remove "use server"
its only for server actions
@gin both things u showed only work on rsc
Polar bearOP
what.
that is a server actions
action
and what does "rsc" mean
@Polar bear and what does "rsc" mean
react server component
everything without "use client"