Repro for Expo

This commit is contained in:
Dan Abramov
2023-11-03 04:26:41 +00:00
parent 9437d743e2
commit 97547c0a51
2 changed files with 16 additions and 56 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ module.exports = function (api) {
],
env: {
production: {
plugins: ['transform-remove-console'],
// plugins: ['transform-remove-console'],
},
},
}
+15 -55
View File
@@ -1,65 +1,25 @@
import 'react-native-url-polyfill/auto'
import 'lib/sentry' // must be near top
import React, {useState, useEffect} from 'react'
import {RootSiblingParent} from 'react-native-root-siblings'
import React, {useEffect} from 'react'
import {Image} from 'expo-image'
// import {Image} from 'react-native'
import * as SplashScreen from 'expo-splash-screen'
import {GestureHandlerRootView} from 'react-native-gesture-handler'
import {observer} from 'mobx-react-lite'
import {QueryClientProvider} from '@tanstack/react-query'
import 'view/icons'
import {withSentry} from 'lib/sentry'
import {ThemeProvider} from 'lib/ThemeContext'
import {s} from 'lib/styles'
import {RootStoreModel, setupState, RootStoreProvider} from './state'
import {Shell} from 'view/shell'
import * as notifications from 'lib/notifications/notifications'
import * as analytics from 'lib/analytics/analytics'
import * as Toast from 'view/com/util/Toast'
import {queryClient} from 'lib/react-query'
import {TestCtrls} from 'view/com/testing/TestCtrls'
SplashScreen.preventAutoHideAsync()
const App = observer(function AppImpl() {
const [rootStore, setRootStore] = useState<RootStoreModel | undefined>(
undefined,
)
export default function App() {
// init
useEffect(() => {
setupState().then(store => {
setRootStore(store)
analytics.init(store)
notifications.init(store)
store.onSessionDropped(() => {
Toast.show('Sorry! Your session expired. Please log in again.')
})
})
SplashScreen.hideAsync()
console.log('hiding splash')
}, [])
// show nothing prior to init
if (!rootStore) {
return null
}
return (
<QueryClientProvider client={queryClient}>
<ThemeProvider theme={rootStore.shell.colorMode}>
<RootSiblingParent>
<analytics.Provider>
<RootStoreProvider value={rootStore}>
<GestureHandlerRootView style={s.h100pct}>
<TestCtrls />
<Shell />
</GestureHandlerRootView>
</RootStoreProvider>
</analytics.Provider>
</RootSiblingParent>
</ThemeProvider>
</QueryClientProvider>
<Image
style={{
flex: 1,
}}
source={{
uri: 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/IMO_9811000_EVER_GIVEN_%2809%29.JPG/800px-IMO_9811000_EVER_GIVEN_%2809%29.JPG',
}}
/>
)
})
export default withSentry(App)
}