bsky-app/src/App.web.tsx

36 lines
871 B
TypeScript
Raw Normal View History

2022-06-09 20:03:25 +02:00
import React, {useState, useEffect} from 'react'
import {RootSiblingParent} from 'react-native-root-siblings'
import {GestureHandlerRootView} from 'react-native-gesture-handler'
2022-07-19 23:04:45 +02:00
import * as view from './view/index'
import {RootStoreModel, setupState, RootStoreProvider} from './state'
import * as Routes from './view/routes'
2022-06-09 20:03:25 +02:00
function App() {
const [rootStore, setRootStore] = useState<RootStoreModel | undefined>(
undefined,
)
2022-06-09 20:03:25 +02:00
// init
useEffect(() => {
2022-07-19 23:04:45 +02:00
view.setup()
2022-06-09 20:03:25 +02:00
setupState().then(setRootStore)
}, [])
// show nothing prior to init
if (!rootStore) {
return null
}
return (
<GestureHandlerRootView style={{flex: 1}}>
<RootSiblingParent>
<RootStoreProvider value={rootStore}>
<Routes.Root />
</RootStoreProvider>
</RootSiblingParent>
</GestureHandlerRootView>
2022-06-09 20:03:25 +02:00
)
}
export default App