Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added feature for passing a custom container component (patch included) #315

Open
ahansson89 opened this issue Jan 27, 2023 · 0 comments
Open

Comments

@ahansson89
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-otp-inputs/src/index.tsx b/node_modules/react-native-otp-inputs/src/index.tsx
index 7fd9e45..16a7b5f 100644
--- a/node_modules/react-native-otp-inputs/src/index.tsx
+++ b/node_modules/react-native-otp-inputs/src/index.tsx
@@ -20,6 +20,7 @@ import {
   TextStyle,
   View,
   ViewStyle,
+  
 } from 'react-native';
 
 import { fillOtpCode } from './helpers';
@@ -39,6 +40,7 @@ type Props = TextInputProps & {
   defaultValue?: string;
   handleChange: (otpCode: string) => void;
   inputContainerStyles?: StyleProp<ViewStyle>;
+  containerComponent?: React.ComponentType<any>;
   inputStyles?: StyleProp<TextStyle>;
   isRTL?: boolean;
   numberOfInputs: number;
@@ -75,6 +77,7 @@ const OtpInputs = forwardRef<OtpInputsRef, Props>(
       selectTextOnFocus = true,
       style,
       testIDPrefix = 'otpInput',
+      containerComponent: ContainerComponent = React.Fragment,
       ...restProps
     },
     ref,
@@ -244,7 +247,8 @@ const OtpInputs = forwardRef<OtpInputsRef, Props>(
         }
 
         return (
-          <OtpInput
+          <ContainerComponent>
+            <OtpInput
             accessible
             accessibilityLabel={`${testIDPrefix}-${inputIndex}`}
             autoCapitalize={autoCapitalize}
@@ -272,7 +276,8 @@ const OtpInputs = forwardRef<OtpInputsRef, Props>(
             selectTextOnFocus={selectTextOnFocus}
             testID={`${testIDPrefix}-${inputIndex}`}
             {...restProps}
-          />
+          /></ContainerComponent>
+          
         );
       });
     };

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant