function ChatIndexComponent() {
const chatId = Route.useParams({ select: (d) => d.chatId });
const { send } = useChatActorRef();
const chatQuery = trpc.chatWithMessages.useQuery(chatId);
const chat = chatQuery.data;
// This seems to run twice, but the subscription isn't disposed of when the component unmounts
trpc.messageStream.useSubscription(
{
chatId,
},
{
enabled: true,
onData: ({ data }) => {
send(data);
},
}
);
function ChatIndexComponent() {
const chatId = Route.useParams({ select: (d) => d.chatId });
const { send } = useChatActorRef();
const chatQuery = trpc.chatWithMessages.useQuery(chatId);
const chat = chatQuery.data;
// This seems to run twice, but the subscription isn't disposed of when the component unmounts
trpc.messageStream.useSubscription(
{
chatId,
},
{
enabled: true,
onData: ({ data }) => {
send(data);
},
}
);