Skip to content

Commit f2aca2a

Browse files
committed
fix: forward ref properly in messaging element
- Remove unused internal ref, use forwarded ref instead - Drop unused imports (HostComponent, NativeProps, useRef)
1 parent 02abde0 commit f2aca2a

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

src/components/PaymentMethodMessagingElement.tsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
import React, { forwardRef, useEffect, useRef, useState } from 'react';
2-
import {
3-
AccessibilityProps,
4-
HostComponent,
5-
LayoutAnimation,
6-
} from 'react-native';
1+
import React, { forwardRef, useEffect, useState } from 'react';
2+
import { AccessibilityProps, LayoutAnimation } from 'react-native';
73
import {
84
PaymentMethodMessagingElementAppearance,
95
PaymentMethodMessagingElementState,
106
} from '../types/components/PaymentMethodMessagingElementComponent';
117
import { PaymentMethodMessagingElementConfiguration } from '../types/components/PaymentMethodMessagingElementComponent';
12-
import NativePaymentMethodMessagingElement, {
13-
NativeProps,
14-
} from '../specs/NativePaymentMethodMessagingElement';
8+
import NativePaymentMethodMessagingElement from '../specs/NativePaymentMethodMessagingElement';
159
import { addListener } from '../events';
1610

1711
export interface Props extends AccessibilityProps {
@@ -51,10 +45,7 @@ export interface Props extends AccessibilityProps {
5145
* @category ReactComponents
5246
*/
5347
export const PaymentMethodMessagingElement = forwardRef<any, Props>(
54-
({ appearance, configuration, onStateChange, ...props }) => {
55-
const viewRef =
56-
useRef<React.ComponentRef<HostComponent<NativeProps>>>(null);
57-
48+
({ appearance, configuration, onStateChange, ...props }, ref) => {
5849
const [height, setHeight] = useState<number | undefined>();
5950

6051
useEffect(() => {
@@ -102,7 +93,7 @@ export const PaymentMethodMessagingElement = forwardRef<any, Props>(
10293
style={[{ width: '100%', height: height }]}
10394
configuration={configuration}
10495
{...props}
105-
ref={viewRef}
96+
ref={ref}
10697
/>
10798
);
10899
}

0 commit comments

Comments
 (0)