From ecdcaa64081d00e4b3fdc30deebf8fa4ffb2450f Mon Sep 17 00:00:00 2001 From: Mark Lawlor Date: Tue, 31 May 2022 12:18:31 +1000 Subject: [PATCH] fix: remove react forwardRef override --- src/styled-component.tsx | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/src/styled-component.tsx b/src/styled-component.tsx index a716c08..eb613e0 100644 --- a/src/styled-component.tsx +++ b/src/styled-component.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import * as React from "react"; import { styled } from "./styled"; import { StyledProps } from "./utils/styled"; @@ -6,26 +7,11 @@ export type StyledComponentProps

= StyledProps

& { component: React.ComponentType

; }; -/** - * This might cause issues in the future, but we provide an override of forwardRef - * to provide better typing of our components - */ -declare module "react" { - // eslint-disable-next-line @typescript-eslint/ban-types - function forwardRef( - render: (props: P, ref: React.Ref) => React.ReactElement | null - ): React.ForwardRefExoticComponent< - React.PropsWithoutRef

& React.RefAttributes - >; -} - -function StyledComponentFunction

( - { component, ...options }: StyledComponentProps

, - ref: React.ForwardedRef -) { - const Component = styled(component); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - return ; -} - -export const StyledComponent = React.forwardRef(StyledComponentFunction); +export const StyledComponent = React.forwardRef( + ({ component, ...options }, ref) => { + const Component = styled(component); + return ; + } +) as ( + props: StyledComponentProps

& React.RefAttributes +) => React.ReactElement | null;