Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit93dfee4

Browse files
committed
🐛 Demo: Fix placeholder not working when numInputs change
Fixesdevfolioco#255
1 parenteccd83f commit93dfee4

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

‎src/demo/index.jsx‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,22 @@ class Demo extends Component {
2727
};
2828

2929
handleChange=e=>{
30-
letcurrVal=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+
letnumInputs=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
/>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp