react-spectrum
react-spectrum copied to clipboard
mergeProps doesn't work for Server Components
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