我正在一个项目上,并且一切正常,突然由于这个错误我的应用程序崩溃了:
Warning: %s: Error boundaries should implement getDerivedStateFromError().
In that method, return a state update to display an error message or fallback UI., RootErrorBoundary
这些文件中的错误:
* src/config/routes.js:31:27 in <unknown>
* src/modules/auth/actions.js:69:29 in <unknown>
包含用于route.js的_this.setState的行:
componentDidMount() {
let _this = this;
store.dispatch(checkLoginStatus((isLoggedIn) => {
_this.setState({isReady: true, isLoggedIn});
}));
}
,并在包含actions.js的回调(isLoggedIn)的行中:
export function checkLoginStatus(callback) {
return (dispatch) => {
auth.onAuthStateChanged((user) => {
let isLoggedIn = (user !== null);
if (isLoggedIn) {
//get the user object from the Async storage
AsyncStorage.getItem('user', (err, user) => {
if (user === null) isLoggedIn = false //set the loggedIn value to false
else dispatch({type: t.LOGGED_IN, data: JSON.parse(user)})
callback(isLoggedIn);
});
} else {
dispatch({type: t.LOGGED_OUT});
callback(isLoggedIn);
}
});
};
}
请帮助我解决此问题。
答案 0 :(得分:-7)
我通过清除应用程序数据来解决