mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import 'array.prototype.findlast/auto'
2/// <reference lib="dom" />
3
4// @ts-ignore whatever typescript wants to complain about here, I dont care about -prf
5window.setImmediate = (cb: () => void) => setTimeout(cb, 0)
6
7if (process.env.NODE_ENV !== 'production') {
8 // In development, react-native-web's <View> tries to validate that
9 // text is wrapped into <Text>. It doesn't catch all cases but is useful.
10 // Unfortunately, it only does that via console.error so it's easy to miss.
11 // This is a hack to get it showing as a redbox on the web so we catch it early.
12 const realConsoleError = console.error
13 const thrownErrors = new WeakSet()
14 console.error = function consoleErrorWrapper(msgOrError) {
15 if (
16 typeof msgOrError === 'string' &&
17 msgOrError.startsWith('Unexpected text node')
18 ) {
19 if (
20 msgOrError ===
21 'Unexpected text node: . A text node cannot be a child of a <View>.'
22 ) {
23 // This is due to a stray empty string.
24 // React already handles this fine, so RNW warning is a false positive. Ignore.
25 return
26 }
27 const err = new Error(msgOrError)
28 thrownErrors.add(err)
29 throw err
30 } else if (!thrownErrors.has(msgOrError)) {
31 return realConsoleError.apply(this, arguments as any)
32 }
33 }
34}