Javascript 错误边界应实现getDerivedStateFromError()

Javascript 错误边界应实现getDerivedStateFromError(),javascript,firebase,react-native,firebase-authentication,Javascript,Firebase,React Native,Firebase Authentication,我正在做一个项目,一切正常,突然我的应用程序因为这个错误崩溃了: 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:2

我正在做一个项目,一切正常,突然我的应用程序因为这个错误崩溃了:

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>
在包含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);
            }
        });
    };
}

请帮助我解决此问题。

我通过清除应用程序数据解决了此问题。

您是否在应用程序中的某个位置(可能在根附近)有/使用错误边界组件(即
rootErrorBoundary
)?它是否实现了
getDerivedStateFromError
?在最近的一次更新中,React的errorBoundary接口发生了一些变化。你能包括
rootErrorBoundary
的代码吗?不,我没有rootErrorBoundary的任何代码。现在我在同一行上有另一个错误:不变冲突:这个Navigator缺少导航道具。嗯,你的action.js中有两行是
回调(isLoggedIn),你知道叫哪个吗?传递的
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);
            }
        });
    };
}