Sathya
Sathya

Reputation: 1734

Throwing "Uncaught ReferenceError: value is not defined" in react range slider

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;

Upvotes: 0

Views: 3606

Answers (1)

Pete TNT
Pete TNT

Reputation: 8403

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} />

Upvotes: 3

Related Questions