File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ type Props = {
23
23
shouldAutoFocus ?: boolean ,
24
24
isInputNum ?: boolean ,
25
25
value ?: string ,
26
- className ?: string
26
+ className ?: string ,
27
27
} ;
28
28
29
29
type State = {
@@ -138,21 +138,22 @@ class OtpInput extends Component<Props, State> {
138
138
getOtpValue = ( ) =>
139
139
this . props . value ? this . props . value . toString ( ) . split ( '' ) : [ ] ;
140
140
141
- getPlaceholderValue = ( ) => {
142
- const { placeholder, numInputs} = this . props ;
141
+ getPlaceholderValue = ( ) => {
142
+ const { placeholder, numInputs } = this . props ;
143
143
144
- if ( ! placeholder ) return ;
145
-
146
- if ( placeholder . length === 1 ) {
144
+ if ( typeof placeholder !== 'string' ) {
145
+ console . error ( "Placeholder should be a string" ) ;
146
+ return ;
147
+ }
148
+
149
+ if ( placeholder . length === 1 ) {
147
150
return placeholder . repeat ( numInputs ) ;
151
+ } else if ( placeholder . length === numInputs ) {
152
+ return placeholder ;
153
+ } else {
154
+ console . error ( 'Invalid placeholder value' ) ;
148
155
}
149
- else if ( placeholder . length === numInputs ) {
150
- return placeholder
151
- }
152
- else {
153
- console . error ( "Invalid placeholder value" ) ;
154
- }
155
- }
156
+ } ;
156
157
157
158
// Helper to return OTP from input
158
159
handleOtpChange = ( otp : string [ ] ) = > {
You can’t perform that action at this time.
0 commit comments