@@ -35,7 +35,7 @@ export default function createImmutable() {
3535 ) : T {
3636 const refAble = supportRef ( Component ) ;
3737
38- const ImmutableComponent = function ( props : any , ref : any ) {
38+ const ImmutableComponent : React . ForwardRefRenderFunction < any , any > = ( props , ref ) => {
3939 const refProps = refAble ? { ref } : { } ;
4040 const renderTimesRef = React . useRef ( 0 ) ;
4141 const prevProps = React . useRef ( props ) ;
@@ -67,7 +67,9 @@ export default function createImmutable() {
6767 ImmutableComponent . displayName = `ImmutableRoot(${ Component . displayName || Component . name } )` ;
6868 }
6969
70- return refAble ? React . forwardRef ( ImmutableComponent ) as unknown as T : ( ImmutableComponent as T ) ;
70+ return refAble
71+ ? ( React . forwardRef ( ImmutableComponent ) as unknown as T )
72+ : ( ImmutableComponent as T ) ;
7173 }
7274
7375 /**
@@ -80,10 +82,9 @@ export default function createImmutable() {
8082 ) : T {
8183 const refAble = supportRef ( Component ) ;
8284
83- const ImmutableComponent = function ( props : any , ref : any ) {
85+ const ImmutableComponent : React . ForwardRefRenderFunction < any , any > = ( props , ref ) => {
8486 const refProps = refAble ? { ref } : { } ;
8587 useImmutableMark ( ) ;
86-
8788 return < Component { ...props } { ...refProps } /> ;
8889 } ;
8990
@@ -93,9 +94,10 @@ export default function createImmutable() {
9394 } )`;
9495 }
9596
96- return refAble
97- ? React . memo ( React . forwardRef ( ImmutableComponent ) , propsAreEqual ) as unknown as T
98- : ( React . memo ( ImmutableComponent , propsAreEqual ) as unknown as T ) ;
97+ return React . memo (
98+ refAble ? React . forwardRef ( ImmutableComponent ) : ImmutableComponent ,
99+ propsAreEqual ,
100+ ) as unknown as T ;
99101 }
100102
101103 return {
0 commit comments