Skip to content

Commit e6ef290

Browse files
committed
Hoist defaultInputStyle out of state into a static constant
1 parent 23a5b4d commit e6ef290

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/ReactCodeInput.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ const BACKSPACE_KEY = 8;
1313
const LEFT_ARROW_KEY = 37;
1414
const RIGHT_ARROW_KEY = 39;
1515

16+
const defaultInputStyle = {
17+
fontFamily: 'monospace',
18+
MozAppearance: 'textfield',
19+
borderRadius: '6px',
20+
border: '1px solid',
21+
boxShadow: '0px 0px 10px 0px rgba(0,0,0,.10)',
22+
margin: '4px',
23+
paddingLeft: '8px',
24+
paddingRight: 0,
25+
width: '36px',
26+
height: '42px',
27+
fontSize: '32px',
28+
boxSizing: 'border-box',
29+
};
30+
1631
class ReactCodeInput extends Component {
1732
constructor(props) {
1833
super(props);
@@ -30,20 +45,6 @@ class ReactCodeInput extends Component {
3045
isValid,
3146
disabled,
3247
filterKeyCodes,
33-
defaultInputStyle: {
34-
fontFamily: 'monospace',
35-
MozAppearance: 'textfield',
36-
borderRadius: '6px',
37-
border: '1px solid',
38-
boxShadow: '0px 0px 10px 0px rgba(0,0,0,.10)',
39-
margin: '4px',
40-
paddingLeft: '8px',
41-
paddingRight: 0,
42-
width: '36px',
43-
height: '42px',
44-
fontSize: '32px',
45-
boxSizing: 'border-box',
46-
},
4748
};
4849

4950
for (let i = 0; i < Number(fields) && i < 32; i += 1) {
@@ -218,7 +219,7 @@ class ReactCodeInput extends Component {
218219
inputMode,
219220
placeholder
220221
} = this.props,
221-
{ disabled, input, isValid, defaultInputStyle } = this.state,
222+
{ disabled, input, isValid } = this.state,
222223
styles = {
223224
container: { display: 'inline-block', ...style },
224225
input: isValid ? inputStyle : inputStyleInvalid,

0 commit comments

Comments
 (0)