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IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;SACvB;IACH,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/**\n * NOTE(brentvatne):\n * AppLoadingPlaceholder exists to smooth the upgrade experience to SDK 40. The\n * placeholder behaves mostly as expected with the existing API, however it\n * will no longer leverage any native APIs to keep the splash screen visible.\n * This makes it so a user who upgrades and runs their app can see their app\n * running and get the warning about the AppLoading module being removed\n * top, without an extraneous red screen that would appear from attempting to\n * render an undefined AppLoading component.\n *\n * Remove this in SDK 42.\n */\n\nimport React from 'react';\n\ntype Props =\n | {\n /**\n * Optional, you can do this process manually if you prefer.\n * This is mainly for backwards compatibility and it is not recommended.\n *\n * When provided, requires providing `onError` prop as well.\n * @deprecated\n */\n startAsync: () => Promise;\n\n /**\n * If `startAsync` throws an error, it is caught and passed into the provided function.\n * @deprecated\n */\n onError: (error: Error) => void;\n\n /**\n * Called when `startAsync` resolves or rejects.\n * This should be used to set state and unmount the `AppLoading` component.\n * @deprecated\n */\n onFinish: () => void;\n\n /**\n * Whether to hide the native splash screen as soon as you unmount the `AppLoading` component.\n * Auto-hiding is enabled by default.\n */\n autoHideSplash?: boolean;\n }\n | {\n /**\n * Whether to hide the native splash screen as soon as you unmount the `AppLoading` component.\n * Auto-hiding is enabled by default.\n */\n autoHideSplash?: boolean;\n };\n\nexport default class AppLoadingPlaceholder extends React.Component {\n _isMounted: boolean = false;\n\n componentDidMount() {\n this._isMounted = true;\n\n this.startLoadingAppResourcesAsync().catch(error => {\n console.error(`AppLoading threw an unexpected error when loading:\\n${error.stack}`);\n });\n }\n\n componentWillUnmount() {\n this._isMounted = false;\n }\n\n private async startLoadingAppResourcesAsync() {\n if (!('startAsync' in this.props)) {\n return;\n }\n\n if (!('onFinish' in this.props)) {\n throw new Error('AppLoading onFinish prop is required if startAsync is provided');\n }\n\n if (!('onError' in this.props)) {\n throw new Error('AppLoading onError prop is required if startAsync is provided');\n }\n\n try {\n await this.props.startAsync();\n } catch (e) {\n if (!this._isMounted) {\n return;\n }\n this.props.onError(e);\n } finally {\n if (!this._isMounted) {\n return;\n }\n // If we get to this point then we know that either there was no error, or the error was handled.\n this.props.onFinish();\n }\n }\n\n render() {\n return null;\n }\n}\n"]}