I am unable to get react-native's this.setState();
to work.
When I run the onUpdate
method, I can see the correct JSON object being returned.
The issue is when the setState
function is called nothing happens and the method fails. No more code is executed below it. It also not re-render the component after the setState
function.
Here is my component code below:
var App = React.createClass({
getInitialState: function() {
return {
view: Login,
menu: false,
}
},
componentDidMount: function() {
var self = this;
},
onUpdate: function(val){
// val is verified as an object here when I log to console
this.setState(val);
// nothing runs here. The above line errors out the function
},
render: function () {
if(this.state.view == 'Home'){
this.refs.sideMenu.frontView = Home;
return (
<View style={styles.container} >
{sideMenu}
</View>
);
}
return (
<View style={styles.container} >
<Login onUpdate={this.onUpdate} />
</View>
);
}
});