1- import { useMemo , createElement } from 'react' ;
1+ import { useMemo , createElement , forwardRef , FC } from 'react' ;
22
33export function $$styled (
44 Comp : any ,
@@ -10,7 +10,7 @@ export function $$styled(
1010 } ;
1111 }
1212) {
13- function StyledComponent ( { as, ...props } : any ) {
13+ const StyledComponent : any = forwardRef ( ( { as, ...props } : any , ref ) => {
1414 let CompToRender = as ?? Comp ;
1515 const [ variants , others ] = useMemo ( ( ) => {
1616 const [ classes , others ] : any [ ] = [ { } , { } ] ;
@@ -31,11 +31,11 @@ export function $$styled(
3131 } , [ variants , props . className ] ) ;
3232
3333 if ( typeof CompToRender === 'string' ) {
34- return createElement ( CompToRender , { ...others , className } ) ;
34+ return createElement ( CompToRender , { ...others , className, ref } ) ;
3535 }
3636
37- return createElement ( CompToRender , { ...props , className } ) ;
38- }
37+ return createElement ( CompToRender , { ...props , className, ref } ) ;
38+ } ) ;
3939
4040 StyledComponent . displayName = `Macaron(${ Comp } )` ;
4141 StyledComponent . toString = ( ) => StyledComponent . selector ( null ) ;
0 commit comments