'How could I get exp in all components so I could handle component error?
I am using expo-error-recovery library. On the App component, if something is wrong, exp is provided. If an error happened in my NavMain or other component, exp is undefined.
const defaultErrorHandler = ErrorUtils.getGlobalHandler();
const globalErrorHandler = (err, isFatal) => {
console.log("err");
ErrorRecovery.setRecoveryProps({ info: err });
defaultErrorHandler(err, isFatal);
};
ErrorUtils.setGlobalHandler(globalErrorHandler);
export default ({ exp }) => {
if (exp.errorRecovery != null) return <ErrorFallback exp={exp} />;
return (
<NavMain />
);
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
