From f09711c3bb21f75fbaae71da4edab2db7f04a742 Mon Sep 17 00:00:00 2001 From: Sascha Tandel Date: Sat, 6 Mar 2021 22:47:37 +0100 Subject: [PATCH] fix: this maybe the global object --- index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 72c74ce..dfd5096 100644 --- a/index.ts +++ b/index.ts @@ -96,7 +96,7 @@ export function styled( tag: Tag = 'div' as Tag, { shouldForwardProp = isPropValid, ...config }: StyledOptions & StyleConfig = {}, ) { - const tw = this || defaultTW + const tw = typeof this == 'function' ? this : defaultTW const component = style(config) @@ -114,7 +114,7 @@ export function styled( const sc = React.forwardRef( ( - { as = (tag as unknown) as T, ...props }: PolymorphicPropsWithRef, T>, + { as = tag as unknown as T, ...props }: PolymorphicPropsWithRef, T>, ref: React.ForwardedRef, ) => React.createElement(as, {