This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.
2021-04-02 02:24:13 +03:00

21 lines
944 B
JavaScript

import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment';
import { Platform } from 'react-native';
import { getRecoveryPropsToSave } from './ErroRecoveryStore';
import ExpoErrorRecovery from './ExpoErrorRecovery';
if (Platform.OS !== 'web') {
const globalHandler = ErrorUtils.getGlobalHandler();
// ErrorUtils came from react-native
// https://github.com/facebook/react-native/blob/1151c096dab17e5d9a6ac05b61aacecd4305f3db/Libraries/vendor/core/ErrorUtils.js#L25
ErrorUtils.setGlobalHandler(async (error, isFatal) => {
if (ExpoErrorRecovery.saveRecoveryProps) {
await ExpoErrorRecovery.saveRecoveryProps(getRecoveryPropsToSave());
}
globalHandler(error, isFatal);
});
}
else if (Platform.OS === 'web' && canUseDOM) {
window.addEventListener('error', () => {
ExpoErrorRecovery.saveRecoveryProps(getRecoveryPropsToSave());
});
}
//# sourceMappingURL=ErrorRecovery.fx.js.map