Open
Description
Provide a general summary of the issue here
#5826 breaks custom components in Next.js
Using composeRenderProps
as a util does not work anymore. The below, previously working pattern throws a build error.
import { composeRenderProps } from 'react-aria-components';
import { twMerge } from 'tailwind-merge';
import { tv } from 'tailwind-variants';
export const focusRing = tv({
base: 'outline outline-blue-600 dark:outline-blue-500 forced-colors:outline-[Highlight] outline-offset-2',
variants: {
isFocusVisible: {
false: 'outline-0',
true: 'outline-2',
},
},
});
export function composeTailwindRenderProps<T>(
className: string | ((v: T) => string) | undefined,
tw: string
): string | ((v: T) => string) {
return composeRenderProps(className, (className) => twMerge(tw, className));
}
π€ Expected Behavior?
App should build
π― Current Behavior
./src/lib/utils.ts
'client-only' cannot be imported from a Server Component module. It should only be used from a Client Component.
The error was caused by importing 'react-aria-components/dist/import.mjs' in './src/lib/utils.ts'.
Import trace for requested module:
./src/lib/utils.ts
./src/app/(site)/layout.tsx
π Possible Solution
Need to create 2 separate files for utils. 1 of them should be marked with "use client"
.
'use client';
import { composeRenderProps } from 'react-aria-components';
import { twMerge } from 'tailwind-merge';
export function composeTailwindRenderProps<T>(
className: string | ((v: T) => string) | undefined,
tw: string
): string | ((v: T) => string) {
return composeRenderProps(className, (className) => twMerge(tw, className));
}
import { tv } from 'tailwind-variants';
export const focusRing = tv({
base: 'outline outline-blue-600 dark:outline-blue-500 forced-colors:outline-[Highlight] outline-offset-2',
variants: {
isFocusVisible: {
false: 'outline-0',
true: 'outline-2',
},
},
});
π¦ Context
No response
π₯οΈ Steps to Reproduce
https://codesandbox.io/p/devbox/spring-http-yq2y79
Version
v1.1.0
What browsers are you seeing the problem on?
Other
If other, please specify.
No response
What operating system are you using?
macOS
π§’ Your Company/Team
No response
π· Tracking Issue
No response
Metadata
Metadata
Assignees
Labels
No labels