@@ -90,7 +90,10 @@ class SingleOtpInput extends PureComponent<*> {
90
90
} = this . props ;
91
91
92
92
return (
93
- < div className = { className } style = { { display : 'flex' , alignItems : 'center' } } >
93
+ < div
94
+ className = { className }
95
+ style = { { display : 'flex' , alignItems : 'center' } }
96
+ >
94
97
< input
95
98
autoComplete = "off"
96
99
style = { Object . assign (
@@ -140,18 +143,19 @@ class OtpInput extends Component<Props, State> {
140
143
141
144
getPlaceholderValue = ( ) => {
142
145
const { placeholder, numInputs } = this . props ;
146
+ if ( placeholder !== undefined ) {
147
+ if ( typeof placeholder !== 'string' ) {
148
+ console . error ( 'Placeholder should be a string' ) ;
149
+ return ;
150
+ }
143
151
144
- if ( typeof placeholder !== 'string' ) {
145
- console . error ( "Placeholder should be a string" ) ;
146
- return ;
147
- }
148
-
149
- if ( placeholder . length === 1 ) {
150
- return placeholder . repeat ( numInputs ) ;
151
- } else if ( placeholder . length === numInputs ) {
152
- return placeholder ;
153
- } else {
154
- console . error ( 'Invalid placeholder value' ) ;
152
+ if ( placeholder . length === 1 ) {
153
+ return placeholder . repeat ( numInputs ) ;
154
+ } else if ( placeholder . length === numInputs ) {
155
+ return placeholder ;
156
+ } else {
157
+ console . error ( 'Invalid placeholder value' ) ;
158
+ }
155
159
}
156
160
} ;
157
161
@@ -291,7 +295,7 @@ class OtpInput extends Component<Props, State> {
291
295
errorStyle,
292
296
shouldAutoFocus,
293
297
isInputNum,
294
- className
298
+ className,
295
299
} = this . props ;
296
300
const otp = this . getOtpValue ( ) ;
297
301
const inputs = [ ] ;
0 commit comments