So I need to run this line of code:
var vehicles = this.state.vehicles;
In the render function:
render: function(){...}
I currently get this error:
Uncaught (in promise) TypeError: Cannot read property 'state' of undefined
Even though this line works:
this.setState({vehicles: json})
This is also part of the code:
getInitialState: function(){
this.render = this.render.bind(this)
return {
vehicles: []
}
}
How can I fix this error and access the data?