我无法让反应本地人this.setState();工作.
当我运行该onUpdate方法时,我可以看到返回正确的JSON对象.
问题是当setState调用函数时没有任何反应,方法失败.它下面不再执行任何代码.它也不会在setState函数后重新渲染组件.
这是我的组件代码如下:
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> …Run Code Online (Sandbox Code Playgroud)