Delete <AppProfiler>

This commit is contained in:
Dan Abramov
2025-01-08 18:43:24 +00:00
parent aa3d8c5230
commit cee324c15a
2 changed files with 36 additions and 68 deletions
+36 -39
View File
@@ -69,7 +69,6 @@ import {NuxDialogs} from '#/components/dialogs/nuxs'
import {useStarterPackEntry} from '#/components/hooks/useStarterPackEntry' import {useStarterPackEntry} from '#/components/hooks/useStarterPackEntry'
import {Provider as IntentDialogProvider} from '#/components/intents/IntentDialogs' import {Provider as IntentDialogProvider} from '#/components/intents/IntentDialogs'
import {Provider as PortalProvider} from '#/components/Portal' import {Provider as PortalProvider} from '#/components/Portal'
import {AppProfiler} from '#/AppProfiler'
import {Splash} from '#/Splash' import {Splash} from '#/Splash'
import {BottomSheetProvider} from '../modules/bottom-sheet' import {BottomSheetProvider} from '../modules/bottom-sheet'
import {BackgroundNotificationPreferencesProvider} from '../modules/expo-background-notification-handler/src/BackgroundNotificationHandlerProvider' import {BackgroundNotificationPreferencesProvider} from '../modules/expo-background-notification-handler/src/BackgroundNotificationHandlerProvider'
@@ -198,44 +197,42 @@ function App() {
* that is set up in the InnerApp component above. * that is set up in the InnerApp component above.
*/ */
return ( return (
<AppProfiler> <GeolocationProvider>
<GeolocationProvider> <A11yProvider>
<A11yProvider> <KeyboardControllerProvider>
<KeyboardControllerProvider> <SessionProvider>
<SessionProvider> <PrefsStateProvider>
<PrefsStateProvider> <I18nProvider>
<I18nProvider> <ShellStateProvider>
<ShellStateProvider> <InvitesStateProvider>
<InvitesStateProvider> <ModalStateProvider>
<ModalStateProvider> <DialogStateProvider>
<DialogStateProvider> <LightboxStateProvider>
<LightboxStateProvider> <PortalProvider>
<PortalProvider> <BottomSheetProvider>
<BottomSheetProvider> <StarterPackProvider>
<StarterPackProvider> <SafeAreaProvider
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
initialMetrics={initialWindowMetrics}> <IntentDialogProvider>
<IntentDialogProvider> <LightStatusBarProvider>
<LightStatusBarProvider> <InnerApp />
<InnerApp /> </LightStatusBarProvider>
</LightStatusBarProvider> </IntentDialogProvider>
</IntentDialogProvider> </SafeAreaProvider>
</SafeAreaProvider> </StarterPackProvider>
</StarterPackProvider> </BottomSheetProvider>
</BottomSheetProvider> </PortalProvider>
</PortalProvider> </LightboxStateProvider>
</LightboxStateProvider> </DialogStateProvider>
</DialogStateProvider> </ModalStateProvider>
</ModalStateProvider> </InvitesStateProvider>
</InvitesStateProvider> </ShellStateProvider>
</ShellStateProvider> </I18nProvider>
</I18nProvider> </PrefsStateProvider>
</PrefsStateProvider> </SessionProvider>
</SessionProvider> </KeyboardControllerProvider>
</KeyboardControllerProvider> </A11yProvider>
</A11yProvider> </GeolocationProvider>
</GeolocationProvider>
</AppProfiler>
) )
} }
-29
View File
@@ -1,29 +0,0 @@
import React, {Profiler} from 'react'
// Don't let it get stripped out in profiling builds (which apply production Babel preset).
const log = (global as any)['con' + 'sole'].log
function onRender(id: string, phase: string, actualDuration: number) {
if (!__DEV__) {
// This block of code will exist in the production build of the app.
// However, only profiling builds of React call `onRender` so it's dead code in actual production.
const message = `<Profiler> ${id}:${phase} ${
actualDuration > 500
? '(╯°□°)╯ '
: actualDuration > 100
? '[!!] '
: actualDuration > 16
? '[!] '
: ''
}${Math.round(actualDuration)}ms`
log(message)
}
}
export function AppProfiler({children}: {children: React.ReactNode}) {
return (
<Profiler id="app" onRender={onRender}>
{children}
</Profiler>
)
}