I am trying to pass the value of the ImageTag entered by the user as well as the locationValue selected from the dropdown menu(selectField of material-ui) to the server via socket.
Here is my code:-
var BaseImageDetails = React.createClass({
getInitialState:function(){
return{
imageTag: '',
locationValue: ''
};
},
contextTypes: {
socket: React.PropTypes.object.isRequired
},
handleImageChange:function(event){
this.setState({imageTag: event.target.value});
console.log(imageTag);
},
handleLocationChange:function(event){
this.setState({locationValue: event.target.value});
console.log(locationValue);
},
clickedBase: function(e){
e.preventDefault();
this.context.socket.emit("baseImageSubmit",{imageTag},{locationValue});
},
render(){
console.log("wwooowwowow" , this.props.locationDetails);
var locationItems = this.props.locationDetails.map(function(locationItem){
return <MenuItem value = {locationItem} primaryText = {locationItem} />
}.bind(this));
console.log("locationItems------------",locationItems);
return(
<div>
<Card>
<CardHeader
title="Please provide the following details ? "
actAsExpander={true}
showExpandableButton={true}
/>
<form onSubmit = {this.clickedBase} >
<TextField hintText="Image Tag"
floatingLabelText="Image Tag"
value = {this.state.imageTag} onChange = {this.handleImageChange}/>
<Divider />
<SelectField
fullWidth={true}
hintText="Select the location of your base-image Dockerfile"
onChange = {this.handleLocationChange}
value = {this.state.locationValue}
maxHeight={200}>
{locationItems}
</SelectField>
<Divider />
<RaisedButton label="Secondary" primary={true}
label="Build" secondary={true}
type = "submit" />
</form>
</Card>
</div>
);
}
});
But while consoling it prints "Uncaught ReferenceError: locationValue is not defined" both for the locationValue and imageTag. Can you guys help me where I am doing wrong....