1import React from 'react';
2// TODO: This will break tree shaking due to how we transpile this package.
3import { Platform } from 'react-native';
4
5import ErrorToastContainer from './toast/ErrorToastContainer';
6
7declare const process: any;
8
9if (!global.setImmediate) {
10  global.setImmediate = function (fn) {
11    return setTimeout(fn, 0);
12  };
13}
14
15if (process.env.NODE_ENV === 'development') {
16  if (Platform.OS === 'web') {
17    // Stack traces are big with React Navigation
18
19    require('./LogBox').default.install();
20  }
21}
22
23export function withErrorOverlay(Comp: React.ComponentType<any>) {
24  if (process.env.NODE_ENV === 'production') {
25    return Comp;
26  }
27  return function ErrorOverlay(props: any) {
28    return (
29      <ErrorToastContainer>
30        <Comp {...props} />
31      </ErrorToastContainer>
32    );
33  };
34}
35