Skip to content

Commit

Permalink
🐛(frontend) have a suspense fallback
Browse files Browse the repository at this point in the history
the app crashed on screen changes, I don't quite get why right now… but
at least this goes around the issue…
  • Loading branch information
manuhabitela committed Jul 21, 2024
1 parent efb5ac5 commit e04b8d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import '@livekit/components-styles'
import '@/styles/index.css'
import { Suspense } from 'react'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
import { useLang } from 'hoofd'
import { Route, Switch } from 'wouter'
import { Screen } from './layout/Screen'
import { HomeRoute } from '@/features/home'
import { NotFound } from './routes/NotFound'
import { RoomRoute, roomIdRegex } from '@/features/rooms'
import { NotFound } from './routes/NotFound'
import './i18n/init'

const queryClient = new QueryClient()
Expand All @@ -17,12 +19,14 @@ function App() {
useLang(i18n.language)
return (
<QueryClientProvider client={queryClient}>
<Switch>
<Route path="/" component={HomeRoute} />
<Route path={roomIdRegex} component={RoomRoute} />
<Route component={NotFound} />
</Switch>
<ReactQueryDevtools initialIsOpen={false} />
<Suspense fallback={<Screen />}>
<Switch>
<Route path="/" component={HomeRoute} />
<Route path={roomIdRegex} component={RoomRoute} />
<Route component={NotFound} />
</Switch>
<ReactQueryDevtools initialIsOpen={false} />
</Suspense>
</QueryClientProvider>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/layout/Screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ReactNode } from 'react'
import { css } from '@/styled-system/css'
import { Header } from './Header'

export const Screen = ({ children }: { children: ReactNode }) => {
export const Screen = ({ children }: { children?: ReactNode }) => {
return (
<div
className={css({
Expand Down

0 comments on commit e04b8d0

Please sign in to comment.