Answer the question
In order to leave comments, you need to log in
How to make different slider step in React?
Please tell me how to make the slider move with different steps , for example (500, 1000, 5000, 10000)?
I can't do anything
class Range extends Component {
state = {
value: "0",
step: "500"
};
handleChange = event => {
let eValue = event.target.value;
let step = this.stepRange(eValue);
this.setState({ value: eValue, step: step });
};
stepRange = eValue => {
if (eValue > 1000) {
return 5000;
}
if (eValue > 5000) {
return 10000;
}
return 500;
};
render() {
return (
<div>
<input
type="range"
min="0"
max="10000"
value={this.state.value}
onChange={this.handleChange}
step={this.state.step}
className={modRange.inputRange}
/>
<p>{this.state.value}</p>
</div>
);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question