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