Skip to content

Commit 830874e

Browse files
author
nafees nazik
committed
fix: always forward ref
1 parent f02aba6 commit 830874e

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

src/index.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,13 @@ export { VariantProps, ClassProp, VariantsSchema, VariantsConfig, ClassValue }
1212

1313
export type IntrinsicElementsKeys = keyof JSX.IntrinsicElements
1414

15-
type ForwardRefFunction = {
16-
(props: any, ref?: any): any
17-
}
18-
19-
export type VariantOBJ<Variants> =
15+
type VariantOBJ<Variants> =
2016
| (Variants extends VariantsSchema
2117
? VariantsConfig<Variants> & ClassProp
2218
: ClassProp)
2319
| undefined
2420

25-
export function styled<T extends IntrinsicElementsKeys>(
26-
Tag: T,
27-
forwardRef?: ForwardRefFunction,
28-
) {
21+
export function styled<T extends IntrinsicElementsKeys>(Tag: T) {
2922
return function wrapper<Variants extends VariantsSchema>(
3023
base?: ClassValue,
3124
config?:
@@ -70,7 +63,7 @@ export function styled<T extends IntrinsicElementsKeys>(
7063
_props.className = cx(classes(), props.className)
7164
}
7265

73-
if (forwardRef) {
66+
if (ref) {
7467
_props.ref = ref
7568
}
7669

@@ -79,6 +72,6 @@ export function styled<T extends IntrinsicElementsKeys>(
7972
return React.createElement(_as, _props)
8073
}
8174

82-
return forwardRef ? forwardRef(StyledWrapper) : StyledWrapper
75+
return React.forwardRef(StyledWrapper)
8376
}
8477
}

0 commit comments

Comments
 (0)