Ad

Throwing "Uncaught ReferenceError: Value Is Not Defined" In React Range Slider

- 1 answer

I have followed the nodejs react range slider component instructions (https://www.npmjs.com/package/react-rangeslider). I have installed all dependencies but still i'm getting "value is not defined" error. I don't know why its happening. Here, i have included my code,

var React  = require('react');
var Slider = require('react-rangeslider');

var Volume = React.createClass({
    getInitialState: function(){
        return {
            value: 10,
        };
    },
    handleChange: function(value) {
        this.setState({
            value: value,
        });
    },
    render: function() {
        return (
            <Slider value={value} orientation="vertical" onChange={this.handleChange} />
        );
    }
});

module.exports = Volume;
Ad

Answer

The variable value here is not defined:

<Slider value={value} orientation="vertical" onChange={this.handleChange} />

Use the value in your state instead

<Slider value={this.state.value} orientation="vertical" onChange={this.handleChange} />
Ad
source: stackoverflow.com
Ad