File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,21 +27,22 @@ class Demo extends Component {
2727 } ;
2828
2929 handleChange = e => {
30- let currVal = e . target . value ;
30+ this . setState ( { [ e . target . name ] : e . target . value } ) ;
31+ } ;
3132
32- if ( e . target . name === 'numInputs' ) {
33- const { minLength, maxLength } = this . state ;
33+ handleNumInputsChange = e => {
34+ let numInputs = e . target . value ;
35+ const { minLength, maxLength } = this . state ;
3436
35- if ( currVal < minLength || currVal > maxLength ) {
36- currVal = 4 ;
37+ if ( numInputs < minLength || numInputs > maxLength ) {
38+ numInputs = 4 ;
3739
38- console . error (
39- `Please enter a value between ${ minLength } and ${ maxLength } `
40- ) ;
41- }
40+ console . error (
41+ `Please enter a value between ${ minLength } and ${ maxLength } `
42+ ) ;
4243 }
4344
44- this . setState ( { [ e . target . name ] : currVal } ) ;
45+ this . setState ( { [ e . target . name ] : parseInt ( numInputs , 10 ) } ) ;
4546 } ;
4647
4748 clearOtp = ( ) => {
@@ -91,7 +92,7 @@ class Demo extends Component {
9192 name = "numInputs"
9293 type = "number"
9394 value = { numInputs }
94- onChange = { this . handleChange }
95+ onChange = { this . handleNumInputsChange }
9596 min = { minLength }
9697 max = { maxLength }
9798 />
You can’t perform that action at this time.
0 commit comments