Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergeProps doesn't work for Server Components #6592

Open
BorisZubchenko opened this issue Jun 21, 2024 · 1 comment
Open

mergeProps doesn't work for Server Components #6592

BorisZubchenko opened this issue Jun 21, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@BorisZubchenko
Copy link

Provide a general summary of the issue here

Using mergeProps in server components gives the following error:

Error: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it.

The only solution is to mark component with 'use-client' directive.

🤔 Expected Behavior?

Being able to use the function in server components.

😯 Current Behavior

Can't be used without client components boundary.

💁 Possible Solution

Function's implementation is pretty straightforward. It uses mergeIds from useId.ts. This function does not use any "client" features, but the file itself imports them. The solution I see is to extract idsUpdaterMap and mergeIds to another file so it doesn't import any hooks/contexts.

🔦 Context

No response

🖥️ Steps to Reproduce

https://stackblitz.com/edit/stackblitz-starters-zsr6u8?file=app%2Fpage.tsx

Here I just import mergeProps to a server component. This is enough to raise the error.

Version

@react-aria/utils 3.24.1

What browsers are you seeing the problem on?

Other

If other, please specify.

No response

What operating system are you using?

Windows

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@snowystinger
Copy link
Member

Seems reasonable

@snowystinger snowystinger added the enhancement New feature or request label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants