@@ -32,7 +32,7 @@ class ReactCodeInput extends Component {
32
32
constructor ( props ) {
33
33
super ( props ) ;
34
34
35
- const { fields, isValid , disabled , filterKeyCodes , forceUppercase } = props ;
35
+ const { fields, forceUppercase } = props ;
36
36
let { value } = props ;
37
37
38
38
if ( forceUppercase ) {
@@ -42,9 +42,6 @@ class ReactCodeInput extends Component {
42
42
this . state = {
43
43
value,
44
44
input : [ ] ,
45
- isValid,
46
- disabled,
47
- filterKeyCodes,
48
45
} ;
49
46
50
47
for ( let i = 0 ; i < Number ( fields ) && i < 32 ; i += 1 ) {
@@ -59,9 +56,7 @@ class ReactCodeInput extends Component {
59
56
60
57
UNSAFE_componentWillReceiveProps ( nextProps ) {
61
58
this . setState ( {
62
- isValid : nextProps . isValid ,
63
59
value : nextProps . value ,
64
- disabled : nextProps . disabled ,
65
60
} ) ;
66
61
}
67
62
@@ -153,8 +148,8 @@ class ReactCodeInput extends Component {
153
148
let input ,
154
149
value ;
155
150
156
- if ( this . state . filterKeyCodes . length > 0 ) {
157
- this . state . filterKeyCodes . some ( ( item ) => {
151
+ if ( this . props . filterKeyCodes . length > 0 ) {
152
+ this . props . filterKeyCodes . some ( ( item ) => {
158
153
if ( item === e . keyCode ) {
159
154
e . preventDefault ( ) ;
160
155
return true ;
@@ -209,17 +204,19 @@ class ReactCodeInput extends Component {
209
204
render ( ) {
210
205
const {
211
206
className,
207
+ disabled,
212
208
style = { } ,
213
209
inputStyle = { } ,
214
210
inputStyleInvalid = { } ,
211
+ isValid,
215
212
type,
216
213
autoFocus,
217
214
autoComplete,
218
215
pattern,
219
216
inputMode,
220
217
placeholder
221
218
} = this . props ,
222
- { disabled , input, isValid } = this . state ,
219
+ { input } = this . state ,
223
220
styles = {
224
221
container : { display : 'inline-block' , ...style } ,
225
222
input : isValid ? inputStyle : inputStyleInvalid ,
0 commit comments