2
我有以下警告:警告:setState(...):只能更新已安装或已安装的组件。这通常意味着您在卸载的组件上调用了setState()。这是一个没有操作。请检查Home组件的代码。如何更改componentDidMount上React Native的状态?
export default class Home extends Component {
constructor(props) {
super(props);
this.state = {
loaded: false,
failed: false
};
}
componentWillMount() {
Actions.auth();
}
componentDidMount() {
Actions.loadUser.completed.listen(this.onLoadUserCompleted.bind(this));
Actions.goHome.listen(this.onGoHome.bind(this));
Actions.logout.listen(this.onLogout.bind(this));
}
onLoadUserCompleted(user) {
let currentUser = DataStore.getCurrentUser();
this.setState ({ loaded: true }); // <=============
}
}