genetic-orange
genetic-orange4mo ago

Error - Pastebin.com

I have been trying to fix this for 6 hours https://pastebin.com/HJfEwNjZ Can't figure it out. i get this error
Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server".
{getList: function, getMany: function, create: ..., update: ..., getOne: ..., deleteOne: ..., getApiUrl: ..., custom: ...}
^^^^^^^^
Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server".
{getList: function, getMany: function, create: ..., update: ..., getOne: ..., deleteOne: ..., getApiUrl: ..., custom: ...}
^^^^^^^^
Pastebin
Error - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
1 Reply
relaxed-coral
relaxed-coral4mo ago
in RSC, you can’t use client functions, or in React Component you can’t use server functions. to fix this, you can export same data provider twice. one for the server, other one for the client. in this example we export same auth provider twice to use in client and server. https://github.com/refinedev/refine/tree/master/examples/with-nextjs/src/providers/auth-provider you can do same thing for data providers too To be more clear, Here we export simple-rest again and with "use-client" to use in client components. https://github.com/refinedev/refine/blob/master/examples/with-nextjs/src/providers/data-provider/index.ts you can export again and you can mark with "use-server" to use in sever components. here is the documentation about this topic https://refine.dev/docs/routing/integrations/next-js/#how-can-i-use-my-providers-in-the-both-server-and-client-side