1 | import { setRecoveryPropsToSave } from './ErroRecoveryStore';
|
2 | import ExpoErrorRecovery from './ExpoErrorRecovery';
|
3 | import './ErrorRecovery.fx';
|
4 |
|
5 | // @docsMissing
|
6 | export const recoveredProps = _getRecoveredProps();
|
7 |
|
8 | // @docsMissing
|
9 | export type ErrorRecoveryProps = Record<string, any>;
|
10 |
|
11 | // @needsAudit
|
12 | /**
|
13 | * Set arbitrary error recovery props. If your project crashes in production as a result of a fatal
|
14 | * JS error, Expo will reload your project. If you've set these props, they'll be passed to your
|
15 | * reloaded project's initial props under `exp.errorRecovery`. Access to `localStorage` is required
|
16 | * on web, or else this will simply be a no-op.
|
17 | *
|
18 | * [Read more about error handling with Expo](/guides/errors).
|
19 | * @param props An object which will be passed to your reloaded project's initial props if the
|
20 | * project was reloaded as a result of a fatal JS error.
|
21 | */
|
22 | export function setRecoveryProps(props: ErrorRecoveryProps): void {
|
23 | setRecoveryPropsToSave(props);
|
24 | }
|
25 |
|
26 | function _getRecoveredProps(): ErrorRecoveryProps | null {
|
27 | if (ExpoErrorRecovery.recoveredProps) {
|
28 | return JSON.parse(ExpoErrorRecovery.recoveredProps);
|
29 | }
|
30 | return null;
|
31 | }
|