flat-fuchsia
flat-fuchsia9mo 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
quickest-silver
quickest-silver9mo 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