-
Notifications
You must be signed in to change notification settings - Fork 242
/
App.tsx
39 lines (35 loc) · 1007 Bytes
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { Suspense } from "react";
import { Composer, Thread } from "@liveblocks/react-comments";
import { RoomProvider, useThreads } from "../liveblocks.config";
import { Loading } from "./components/Loading";
import { ErrorBoundary } from "react-error-boundary";
/**
* Displays a list of threads, along with a composer for creating
* new threads.
*/
function Example() {
const { threads } = useThreads();
return (
<main>
{threads.map((thread) => (
<Thread key={thread.id} thread={thread} className="thread" />
))}
<Composer className="composer" />
</main>
);
}
export default function App({ roomId }: { roomId: string }) {
return (
<RoomProvider id={roomId} initialPresence={{}}>
<ErrorBoundary
fallback={
<div className="error">There was an error while getting threads.</div>
}
>
<Suspense fallback={<Loading />}>
<Example />
</Suspense>
</ErrorBoundary>
</RoomProvider>
);
}