React.js , volume-slider

my volume slider is fixed and don’t slide , i want the volume display change as i drag the slider can u help me
class Padbank extends React.Component {
constructor(props){
super(props);
this.state = {
volumeVal: 0.4
}
}

handleVolume = (e) => {
if(this.state.switch){
this.setState({
volumeVal: e.target.value
})
}
}
render() {
return(





Volume: {Math.round(this.state.volumeVal*100)}%




Couple things to notice here.

This won’t work because you have no switch property in your state.

This won’t work. You can’t return a JS object inside JSX.

I would find try to make a slider using html and css first. Then I would integrate inside of react and hook it up like regular input boxes. There are plenty of resources out there on how to do this.

Good luck!

1 Like

omg , it’s a “this.props.switch” because it’s from other component, i feel so stupid xD ty so much everything is fine now <3